如果 在 变量 var c 的 computed里面改变值//return this.size.trim().toLowerCase() 也是报错的 教程上的 // 想在 这里 val 转换大写 // val是个对象 <!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="./node_modules/vue/dist/vue.min.js"></script> <title>Document</title></head><body> <div id="app"> {{msg}} <input v-model="msg" /> <top-box v-bind:msg=msg></top-box> <info-box :msg=msg></info-box> <my-component></my-component> <change-component msg=msg></change-component> </div> <script src="components.js"></script> <script> console.log(top) // window.top in borwer // var top={ var t={ "props":["msg"], "template":`<div> 1111<div>{{msg}}</div> <div>{{msg}}</div> </div>` } var c={ "props":{ msg:String }, template:`<div> <br/><label>组件</label> <textarea>{{msg}}</textarea> </div>`, computed:{ msg:{ get:function(val){ //return this.size.trim().toLowerCase() 也是报错的 教程上的 // 想在 这里 val 转换大写 // val是个对象 return val } } } } var Child = { template: '<div>A custom component!</div>' } // var app= new Vue({ "el":"#app", data(){ return {"msg":"successs"} }, "components":{ "top-box":t, "my-component":Child, "info-box":{ "props":["msg"], "template":`<textarea v-model="msg"></textarea>` }, "change-component":c, } }) </script></body></html>
添加回答
举报
0/150
提交
取消