码迷,mamicode.com
首页 > 其他好文 > 详细

vue组件-模板

时间:2017-08-24 01:15:25      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:methods   com   src   utf-8   body   lang   his   ret   doc   

1

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="bower_components/vue/dist/vue.js"></script>
    <style>
    </style>
</head>
<body>
    <div id="box">
        <my-aaa></my-aaa>
    </div>

    <script type="x-template" id="aaa">
        <h2 @click="change">标题2->{{msg}}</h2>
        <ul>
            <li>1111</li>
            <li>222</li>
            <li>3333</li>
            <li>1111</li>
        </ul>
    </script>

    <script>
        var vm=new Vue({
            el:#box,
            components:{
                my-aaa:{
                    data(){
                        return {
                            msg:welcome vue
                        }
                    },
                    methods:{
                        change(){
                            this.msg=changed;
                        }
                    },
                    template:#aaa
                }
            }
        });

    </script>
</body>
</html>

2

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="bower_components/vue/dist/vue.js"></script>
    <style>
    </style>
</head>
<body>
    <div id="box">
        <my-aaa></my-aaa>
    </div>

    <template id="aaa">
        <h1>标题1</h1>
        <ul>
            <li v-for="val in arr">
                {{val}}
            </li>
        </ul>
    </template>

    <script>
        var vm=new Vue({
            el:#box,
            components:{
                my-aaa:{
                    data(){
                        return {
                            msg:welcome vue,
                            arr:[apple,banana,orange]
                        }
                    },
                    methods:{
                        change(){
                            this.msg=changed;
                        }
                    },
                    template:#aaa
                }
            }
        });

    </script>
</body>
</html>

 

vue组件-模板

标签:methods   com   src   utf-8   body   lang   his   ret   doc   

原文地址:http://www.cnblogs.com/lanlanJser/p/7420948.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!