zoukankan      html  css  js  c++  java
  • vue-cli脚手架使用-- 初学者

    第一步:

        安装环境:

       1. npm install webpack -g

       2. npm install vue-cli -g

       3. vue init webpack-simple

       出现

        

        4. npm install 

        5. npm install vue-router vue-resource --save

        6. npm run dev 

        出现下图  说明成功

        

        写代码正式开始:

             最简单的写法:

             直接在App-vue写如你的代码  如:

             

        2.使用组件写代码:component

            a. 在src目录下先建一个component目录  在目录里面创建一个firstcomponent.js文件 如图

       

            

           

    第一步,引入。在<script></script>标签内的第一行写

    import firstcomponent from './component/firstcomponent.vue'

    第二步,注册。在<script></script>标签内的 data 代码块后面加上 components: { firstcomponent }。记得中间加英文逗号!!!

    export default {
      data () {
        return {
          msg: 'Hello Vue!'
        }
      },
      components: { firstcomponent }
    }

    第三步,使用
    <template></template>内加上<firstcomponent></firstcomponent>

    <template>
        <div id="app">
        <img src="./assets/logo.png"> <h1>{{ msg }}</h1> <firstcomponent></firstcomponent> </div>
    </template>

       完整代码:

       

    路由:

      第一种: 在 main.js中路由  不推荐

       在component目录中创建secondconponent 文件

       在App.vue中写如  如图;

         

      在main.js中的代码:

       

       

      

        

  • 相关阅读:
    搭建 mariadb 数据库主从同步
    MySQL--MVCC
    剑指 Offer 07. 重建二叉树
    剑指 Offer 06. 从尾到头打印链表
    MySQL--数据库范式
    剑指 Offer 05. 替换空格
    剑指 Offer 04. 二维数组中的查找
    剑指offer_03_数组中重复的数字(Java)
    Redis
    MySQL--SQL执行过程
  • 原文地址:https://www.cnblogs.com/gaosen/p/6798563.html
Copyright © 2011-2022 走看看