<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Vue.extend 构造器的延伸</title> <meta name="flexible" content="initial-dpr=2,maximum-dpr=3" /> <meta name="apple-mobile-web-app-capable" content="yes"> <meta content="yes" name="apple-touch-fullscreen"> <meta content="telephone=no,email=no" name="format-detection"> <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"> <script src="../assets/js/flexible_css.js"></script> <script src="../assets/js/flexible.js"></script> <script src="../assets/js/vue.js"></script> </head> <body> <div id="app"> <h1>Vue.extend扩展实例构造器</h1> <div id="author"></div> <author></author> </div> <script type="text/javascript"> var authorURL=Vue.extend({ //延伸、扩展 authorURL就是返回的“扩展实例构造器” template:"<p><a :href='authorUrl'>{{authorName}}</a></p>", // 模版 data:function(){ //数据 return{ authorName:"caicai", authorUrl:"https://baidu.com" } } }) //挂载 new authorURL().$mount("#author"); //mount, 意思为挂载。可以理解为将vue实例(逻辑应用),挂靠在某个dom元素(载体)上的一个过程。 #author 绑定在id为author的元素上 new authorURL().$mount("author"); // 挂载到author标签上 </script> </body> </html>