vue配置对象

data: 数据

template: 字符串,配置模版   参考: https://www.cnblogs.com/kaibindirver/p/13285430.html

el:配置挂载区域

methods: 配置方法

computed: 配置计算属性 里面的函数可以当变量去调用 可以设置访问、赋值分别执行什么

参考视频后面的50分钟后才有开始https://ke.qq.com/webcourse/index.html#cid=2588158&term_id=102693719&taid=9173259872861694&vid=5285890803466783663

var vm = new Vue({
//配置
  el : "#app",//配置模版

  template:`<h1>{{title}}</h1>`,
  data : {
    //配置数据
      title: "商品管理",
      newProduct:{
      name:"",
      stock:"",
      },

  computed:{

  fullName:{

  访问这个函数时走这里, 调用和methods函数里面有区别,这里是直接 {{fullName}} 当值去调用就可以了

  get(){

  console.log("执行操作")

  return this.title

}

  给这个函数赋值时执行走这里的逻辑 如vm.fullName=333

  set(val){

  console.log("执行操作")

}

},
  //创建函数 写在methods里面
  methods:{
    handleDelete(i){
      this.products.splice(i,1);
    },
});

方法里面调用方法的办法(注意是直接this函数的名字即可)

原文地址:https://www.cnblogs.com/kaibindirver/p/13288023.html