Vue x-template的使用与学习

<!DOCTYPE html>
<html lang="en">

<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">
    <title>x-template的使用学习</title>
</head>

<body>
    <div id='app'>
        <my-component></my-component>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>

 <!-- 组件内容 id为 my-component   type 为text/x-template  -->
<script type='text/x-template' id='my-component'>
<div>  这是组件内容</div>
</script>

<script>
    // 声明一个组件 my-component 引入id 为my-component
    Vue.component('my-component', {
        template: '#my-component'
    })

    var app = new Vue({
        el: '#app'
    })
</script>

</html>

github code 地址

猜你喜欢

转载自blog.csdn.net/qq_20472061/article/details/82428160
今日推荐