Git Product home page Git Product logo

moon-vue-ts's Introduction

moon-vue-ts

作业完成情况

  • 动态左侧菜单获取
  • 左侧菜单有子菜单和无子菜单的处理
  • 权限管理 -> 资源列表 - 完成
  • 权限管理 -> 菜单列表 - 完成
  • 权限管理 -> 角色列表 - (菜单分配和资源分配 未完成)

说明一下,平时工作就是vue的业务,所以有些CRUD的业务就不写了. 把时间花在更有意义的事情上.

## Project setup
npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Lints and fixes files

npm run lint

Customize configuration

See Configuration Reference.

依赖项 dependencies

  • vue-class-component 提供使用 Class 语法写 Vue 组件
  • vue-property-decoratorClass 语法基础之上提供一些辅助装饰器
  • @typescript-eslint/eslint-plugin 使用 EsLint校验 TypeScript代码
  • @typescript-eslint/parserTypeScript转为 ASTESLint校验使用
  • @vue/cli-plugin-typescript 使用 TypeScript + ts-loader + fork-ts-checker-webpack-plugin进行更快的类型检查
  • @vue/eslint-config-typescript: 兼容 ESLintTypeScript校验规则
  • typescript: TypeScript 编译器,提供类型校验和转换 JavaScript功能

tsconfig.json

src/shims-tsx.d.ts

shims-vue.d.ts

装饰器

装饰器就是一个函数, 扩展类型的属性和功能

使用 TS 定义组件的 3 种方式

// 方式1: OptionsAPIs --- Vue.extend
import Vue from 'vue'
export default Vue.extend({
  // 使用 Vue.extend({})的方式才能有类型注解和校验才会有效果
  data() {
    return {
      person: {
        name: 'lelsie',
        age: 18
      }
    }
  },
  methods: {
    handle(): string {
      console.info(this.person.name)
      return this.person.name
    }
  }
})
// 方式2: ClassAPIs: extends Vue
import Vue from 'vue'
import Component from 'vue-class-component'

// Define the component in class-style
@Component
export default class App extends Vue {
  // class properties will be component data
  count = 0
  // methods will be component methods
  handle() {
    console.info(this.count)
  }
}
// 方式3: ClassAPIs + decorator
import { Vue, Component, Prop } from 'vue-property-decorator'
@Component
export default class App extends Vue {
    @Prop(Number) readonly propA: number | undefined
    @Prop({default: 'default value'}) readonly propB!: string
    @Prop([String,Boolean]) readonly propC: string | boolean | undefined
}
/**
 * props: {
    propA: {
      type: Number,
    },
    propB: {
      default: 'default value',
    },
    propC: {
      type: [String, Boolean],
    },
  }
 */

作业要求

moon-vue-ts's People

Stargazers

suzhen avatar

Watchers

James Cloos avatar suzhen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.