12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <div id="app">
- {{msg}}
- <br>
- {{msg.split('')}}
- <br>
- 方法: {{newMsg1()}}
- <br>
- 计算属性: {{newMsg2}}
- </div>
- <script src="vue.js"></script>
- <script>
- var app = new Vue({
- el: '#app',
- data: {
- msg: 'hello word'
- },
- methods: {
- newMsg1(){
- return this.msg.split('')
- }
- },
- computed: {
- /* 计算属性 依赖于其他的值去进行计算 并且缓存 */
- /*
- 在vue中 computed 比较特殊的属性 它的值是根据其他的值进行计算出来的结果
- computed 可以使用get或者set的方法 来实现数据的读取和设置
- */
- newMsg2: function(){
- return this.msg.split('')
- }
- }
- })
- </script>
- </body>
- </html>
|