var vm = new Vue({ el: "#app", data: { name: "苹果", price: 10, num: 1 }, components:{ "goods":goods } });var goods = { template: "", props: ["name",'price','num'], computed:{ totle:function(){ console.log(this) return this.num*this.price } },methods: { jia: function() { this.$parent.num++ zhixiang指向vm.num }, jian: function() { this.$parent.num-- } } }名字:{
{name}}价格:{
{price}}数量:{
{num}}总价:{
{totle}}