<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <style> </style> <body> <!-- 全局自定义指令 --> <div id="abc"> <child-a :a="msg"></child-a> </div> <script src="./js/vue.js"></script> <script> Vue.component('child-a', { template: `<div>我是child-a组件---{{a}}</div>`, //写个新选项prop props: ['a'] }) var vm = new Vue({ el: '#abc', //模板ajax返回的数据 data: { msg: "geyao" }, //实例选项 methods: { }, }) </script> <script> /* var a = 0; a = 10; console.log(a); */ </script> <!-- 列表渲染 --> <!-- 1渲染数组 --> <!-- 2c处理无数据的时候 --> </body> </html>