vue.extend 扩展实例构造器一般与组件联合使用
代码示例如下:
<!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>vue.extend 扩展实例构造器</title>
<script src="../assets/js/vue.js"></script>
</head>
<body>
<h1>vue.extend 扩展实例构造器</h1>
<hr>
<div id="author"></div>
<script>
var authorURL = Vue.extend({
template: '<p><a :href="authorURL">{{authorName}}</a></p>',
data () {
return {
authorName: 'http://wwww.baidu.com',
authorURL: 'http://wwww.baidu.com'
}
}
})
new authorURL().$mount("#author")
</script>
</body>
</html>
![](https://i-blog.csdnimg.cn/blog_migrate/d773aaf9133f670791e3811c55fff457.png)