vue组件模块抽离
作者:互联网
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<div id="app">
<comp>
</comp>
</div>
<!-- 法一 -->
<script type="text/x-text/x-handlebars-template" id="comp1">
<div id="">
<p>Hello Vue.js!</p>
<p>Hello furong!</p>
</div>
</script>
<!-- 法二 -->
<template id="comp2">
<div id="">
<p>Hello Vue.js!</p>
<p>Hello furong!</p>
</div>
</template>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!',
},
components: {
comp: {
template: '#comp1',
},
}
})
</script>
</body>
</html>
标签:furong,vue,app,抽离,js,Vue,组件,Hello 来源: https://www.cnblogs.com/zhangxuechao/p/14973832.html