<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://npmcdn.com/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
</div>
<script>
var MyComponent = Vue.extend({
template: '<div>Hello World</div>'
})
var myAppendTo = Vue.extend({
template:'<p>appendTo</p>'
})
var myBefore = Vue.extend({
template:'<p>before</p>'
})
var myAfter = Vue.extend({
template:'<p>after</p>'
})
// 创建并挂载到 #app (会替换 #app)
new MyComponent().$mount('#app')
// 手动挂载
new myAppendTo().$mount().$appendTo('#app');//appendTo
new myBefore().$mount().$before('#app');//before
new myAfter().$mount().$after(
【瑞模网】vue.js的插入dom节点方式
最新推荐文章于 2024-01-23 09:14:12 发布