vue—使用引入的方式创建项目


原文链接:这里
0.前言

上一篇文章是用vue-cli脚手架创建的项目,这篇文章我们使用引入的方式来创建一个项目并运行。

1.引入vue

根据官网的介绍,vue的引入方式有下面这几种



或者

参考代码:

<html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>vue测试title> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js">script> head> <body> <div id="first"> <h2>Hello, {{name}}h2> div>   <script type="text/javascript">     new Vue({ el:'#first', data:{ name:"world" }   })     script> body> html>

效果如下:

注意:实例和容器要一一对应,不要一对多,或者多对一的情况。

vue