Typescript基于vue cli3中一些常见的写法

vue-property-decorator的装饰器的使用

@Component



@Provide


@Emit



@Prop接收父组件传递的数据()里面定义接收的类型


@Watch监听属性
@Model接收父组件双向数据绑定的数据
@Inject注入 正常情况下使用Provide


计算属性







Vuex

//store.ts
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    flag: false,
  },
  mutations: {
    changeState(state) {
      state.flag = !state.flag;
    },
  },
  actions: {

  },
});

//组件中




你可能感兴趣的:(typescript+vue,typescript)