computed \ methods 里边是(各种)函数,函数里边调用变量用this.
computed 里边是 (各种)函数返回对象
实例中data是对象, 在组件中(在其他里边)data是函数返回对象
push() 方法可向数组的末尾添加一个或多个元素,并返回新的长度。
v-model:把当前这个input里边的值指到哪里
<input v-model="current.title" id="task-input" type="text">
JSON.stringify() 方法将 javascript对象 转换为 JSON字符串。
JSON.parse() 方法将 JSON字符串 转换为 JavaScript对象。
<p id="demo"></p> <script> var obj = { "name":"runoob", "alexa":10000, "site":"www.runoob.com"}; var myJSON = JSON.stringify(obj); document.getElementById("demo").innerhtml = myJSON; </script> //运行结果:{"name":"runoob","alexa":10000,"site":"www.runoob.com"}
<p id="demo"></p> <script> var text = ‘{"employees":[‘ + ‘{"name":"菜鸟教程","site":"http://www.runoob.com" },‘ + ‘{"name":"Google","site":"http://www.Google.com" },‘ + ‘{"name":"Taobao","site":"http://www.taobao.com" }]}‘; obj = JSON.parse(text); document.getElementById("demo").innerHTML = obj; </script> //运行结果:[object Object] <p id="demo"></p> <script> var text = ‘{"employees":[‘ + ‘{"name":"菜鸟教程","site":"http://www.runoob.com" },‘ + ‘{"name":"Google","site":"http://www.Google.com" },‘ + ‘{"name":"Taobao","site":"http://www.taobao.com" }]}‘; obj = JSON.parse(text); document.getElementById("demo").innerHTML = obj.employees[1].name; </script> //运行结果:Google
<p id="demo"></p> <script> var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; document.getElementById("demo").innerHTML = person; </script> //运行结果:[object Object]
<p id="demo"></p> <script> var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; document.getElementById("demo").innerHTML = person.firstName; </script> //运行结果:John