在Vue+JavaScript模式中,我们在组件中使用component、watch、model、emit属性时,都是直接使用的.然而在Vue+TypeScript开发模式中.我们需要通过引入相应的构造器,在构造器中进行声明使用数据.
// 在Vue+TypeScript开发模式中引入相应的构造器进行界面开发
<script lang="ts">
import {
Component,Vue,Watch,Prop,Model,Emit} from 'vue=property-decorator'; // 引入相应的构造器
@Component({
// ...通过在构造器Component中注册组件
name:"当前页面的名称",
components:{
...组件的注册
}
})
export default class 页面名称 extends Vue{
// 通过继承Vue构造器,在该类里面书写初始化数据
// 在Vue+JavaScript开发模式中写在data属性中的数据,直接在类里面书写
变量名:变量类型= 初始值
// 在Vue+TypeSCript开发模式中,计算属性的声明通过在类里面使用 get与set关键字声明
get