typescript+vue写法对比

vue 写法

import {mapGetters, mapActions} from 'vuex'
import tree from './components/all/tree/tree.vue'
export default{
   data () {
     return {
       a: 1,
       b: '2',
       c: true,
       d: {
         a: 'qi',
         b: 77
       }
     }
   },
   components: {},
   computed: {},
   methods:{
     funA () {},
     funB () {}
   },
   watch: {},
   mounted () {},
   created () {}
 }

typescript 的写法

import Vue from 'vue'
import Component from 'vue-class-component'
import {mapGetters, mapActions} from 'vuex'

import tree from './components/all/tree/tree.vue'

interface obj {
  a: string;
  b: number;
}
@Component({
  props: [],
  components: {},
  computed: {},
  watch: {},
  mounted () {},
  created () {}
})
export default class a extends Vue {
  // data
  a:number = 1
  b:string = '2'
  c:boolean = true
  d:obj = {
    a: 'qi',
    b: '77'
  }
  // methods
  funA () {}
  funB () {}
}

你可能感兴趣的:(vue)