97国产精品视频人人做人人爱,3344在线观看无码,成年人国产视频,欧美日一级片,在线看AV天堂,高清无码一本到东京热,欧美一级黄片一区2区,免费又爽又刺激高潮网址

Vue cli之全家桶搭建項(xiàng)目

2019-8-19    seo達(dá)人

一、搭建cli

1.事先安裝好cnpm(淘寶鏡像)



npm install -g cnpm --registry=https://registry.npm.taobao.org

1

2.cnpm install -g vue-cli



全局安裝vue腳手架工具。(下載一次就好)



3.vue init webpack your_project_name



創(chuàng)建一個腳手架項(xiàng)目(每次創(chuàng)建需要)



eg:這時在命令行中有需要你填的信息{

你的項(xiàng)目名;

你的項(xiàng)目描述;

還有你想是否下載的插件(y/n);

}



4.使用 npm run dev來運(yùn)行項(xiàng)目



就這樣,一個簡單的vue開發(fā)項(xiàng)目模板就這樣下載完成了。



eg:

i 是install 的簡寫。

全局安裝依賴:



cnpm i   依賴名

1

局部安裝依賴:



cnpm i -D  依賴名

1

二、vue-router

一般事先安裝模板時,已經(jīng)安裝上了。

可以查看package.json中。

如果沒有安裝



cnpm i -D vue-router

1

安裝好之后,在src目錄中會生成一個router目錄,里面放著index.js,

一般有兩種配置

第一種:



import Vue from 'vue';

import Router from 'vue-router';

Vue.use(Router);

export default new Router({

    routes: [

// 一進(jìn)入就顯示頁面

        {

            path: '/',

            redirect: '/index'

        },

        {

            path: '/',

            component: pather => require(['../components/common/bodys.vue'], pather),

            meta: { title: '主體' },

            children:[

                {

                    path: '/index',

                    component: pather => require(['../components/page/index.vue'], pather),

                    meta: { title: '系統(tǒng)首頁' }

                },

                {

                    path: '/biaoge',

                    component: pather => require(['../components/page/biaoge.vue'], pather),

                    meta: { title: '基礎(chǔ)表格' }

                },

                {

                    path: '/Tab',

                    component: pather => require(['../components/page/Tab.vue'], pather),

                    meta: { title: 'tab選項(xiàng)卡' }

                },

                {

                    path: '/jibenbiaodan',

                    component: pather => require(['../components/page/jibenbiaodan.vue'], pather),

                    meta: { title: '基本表單' }

                },

                {

                    path: '/fuwenben',

                    component: pather => require(['../components/page/fuwenben.vue'], pather),

                    meta: { title: '富文本編輯器' }

                },

                {

                    path: '/bianjiqi',

                    component: pather => require(['../components/page/bianjiqi.vue'], pather),

                    meta: { title: 'markdown編輯器' }    

                },

                {

                    path: '/shangchuan',

                    component: pather => require(['../components/page/shangchuan.vue'], pather),

                    meta: { title: '文件上傳' }   

                },

                {

                    path: '/scharts',

                    component: pather => require(['../components/page/scharts.vue'], pather),

                    meta: { title: 'schart圖表' }

                },

                {

                    path: '/tuozhuai',

                    component: pather => require(['../components/page/tuozhuai.vue'], pather),

                    meta: { title: '拖拽列表' }

                },

                {

                    path: '/quanxianceshi',

                    component: pather => require(['../components/page/quanxianceshi.vue'], pather),

                    meta: { title: '權(quán)限測試', permission: true }

                }             

            ]

        },

        {

            path: '/login',

            component: pather => require(['../components/page/login.vue'], pather)

        },



        {

            path: '/cuowu404',

            component: pather => require(['../components/page/cuowu404.vue'], pather)

        },

        {

            path: '/cuowu403',

            component: pather => require(['../components/page/cuowu403.vue'], pather)

        },

        {

            path: '*',

            redirect: '/404'

        }

    ],

// 去掉#號

mode:"history"

})





第二種:



import Vue from 'vue'

import Router from 'vue-router'

import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)



export default new Router({

  routes: [

    {

      path: '/',

      name: 'HelloWorld',

      component: HelloWorld

    }

  ]

})



三、axios

先安裝



cnpm i -D axios

1

然后在main.js寫入



import axios from 'axios'



Vue.prototype.$axios = axios

1

2

3

這樣就可以在組件中使用axios 獲取數(shù)據(jù)了



    loadData(){

            this.$axios.get(['
                .then((response) => {

                    // success

                    console.log(response.data);

                })

                .catch((error) => {

                    //error

                    console.log(error);

                })

        },



四、vuex

1、安裝



cnpm i -D vuex

1

2、然后需要手動創(chuàng)建一個文件夾store在src目錄當(dāng)中,

接著在store文件夾中創(chuàng)建store.js

例:



import Vue from 'vue'

import Vuex from 'vuex'

Vue.use(Vuex)



export default new Vuex.Store({

  state: {

    count: 0

  },

  mutations: {

    increment: state => state.count++,

    decrement: state => state.count--,

  }

})

1

2

3

4

5

6

7

8

9

10

11

12

13

3、然后在main.js引入注冊



import Vuex from 'vuex'

import store from './store/store'



Vue.use(Vuex)



new Vue({

  el: '#app',

  router,

  store,

  components: { App },

  template: '<App/>'

})



比如在headers.vue使用vuex



<template>

    <div class="headers">

     <p>{{count}}</p>

     <button @click="increment">+</button>

     <button @click="decrement">-</button>

    </div>

</template>

<script>

import { mapState } from 'vuex'

export default {

  name: 'headers',

  data () {

    return {

      msg: 'Welcome to Your Vue.js App'

    }

  },

  methods: {

        increment(){

          this.$store.commit('increment')

        },

        decrement(){

          this.$store.commit('decrement')

        }

  },

    computed:{

        count(){

            return this.$store.state.count

        },

    }



}

</script>

<style scoped lang="scss" >

</style>





五、sass

1、需要安裝sass

(1)安裝node-sass

(2)安裝sass-loader

(3)安裝style-loader 有些人安裝的是 vue-style-loader 其實(shí)是一樣的!



cnpm install node-sass --save-dev 

cnpm install sass-loader --save-dev  

cnpm install style-loader --save-dev

1

2

3

2、接著需要更改build文件夾下面的webpack.base.config.js



'use strict'

const path = require('path')

const utils = require('./utils')

const config = require('../config')

const vueLoaderConfig = require('./vue-loader.conf')



function resolve (dir) {

  return path.join(dirname, '..', dir)

}







module.exports = {

  context: path.resolve(
dirname, '../'),

  entry: {

    app: './src/main.js'

  },

  output: {

    path: config.build.assetsRoot,

    filename: '[name].js',

    publicPath: process.env.NODE_ENV === 'production'

      ? config.build.assetsPublicPath

      : config.dev.assetsPublicPath

  },

  resolve: {

    extensions: ['.js', '.vue', '.json'],

    alias: {

      'vue$': 'vue/dist/vue.esm.js',

      '@': resolve('src'),

    }

  },

  module: {

    rules: [

      {

        test: /.vue$/,

        loader: 'vue-loader',

        options: vueLoaderConfig

      },

      {

        test: /.js$/,

        loader: 'babel-loader',

        include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]

      },

      {

        test: /.(png|jpe?g|gif|svg)(\?.)?$/,

        loader: 'url-loader',

        options: {

          limit: 10000,

          name: utils.assetsPath('img/[name].[hash:7].[ext]')

        }

      },

      {

        test: /.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.
)?$/,

        loader: 'url-loader',

        options: {

          limit: 10000,

          name: utils.assetsPath('media/[name].[hash:7].[ext]')

        }

      },

      {

        test: /.(woff2?|eot|ttf|otf)(\?.*)?$/,

        loader: 'url-loader',

        options: {

          limit: 10000,

          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')

        }

      },

      { //從這一段上面是默認(rèn)的!不用改!下面是沒有的需要你手動添加,相當(dāng)于是編譯識別sass! 

        test: /.scss$/,

        loaders: ["style", "css", "sass"]

      }

    ]

  },

  node: {

    // prevent webpack from injecting useless setImmediate polyfill because Vue

    // source contains it (although only uses it if it's native).

    setImmediate: false,

    // prevent webpack from injecting mocks to Node native modules

    // that does not make sense for the client

    dgram: 'empty',

    fs: 'empty',

    net: 'empty',

    tls: 'empty',

    child_process: 'empty'

  }

}





3、在你需要使用sass的地方寫入即可



 <style lang="scss" scoped="" type="text/css"> 

 $primary-color: #333; 

   body {

        color: $primary-color;

       } 

</style>



六、vue UI庫

這里已著名的Element組件庫為例

https://element.eleme.cn/#/zh-CN/component/carousel



1、安裝



npm i element-ui -S

1

2、使用

在main.js寫入



import ElementUI from 'element-ui'

import 'element-ui/lib/theme-chalk/index.css'



Vue.use(ElementUI)

1

2

3

4

3、然后在組件使用就可以了

例:輪播圖



<template>

  <el-carousel indicator-position="outside">

    <el-carousel-item v-for="item in 4" :key="item">

      <h3>{{ item }}</h3>

    </el-carousel-item>

  </el-carousel>

</template>



<style>

  .el-carouselitem h3 {

    color: #475669;

    font-size: 18px;

    opacity: 0.75;

    line-height: 300px;

    margin: 0;

  }

  

  .el-carousel
item:nth-child(2n) {

    background-color: #99a9bf;

  }

  

  .el-carousel__item:nth-child(2n+1) {

    background-color: #d3dce6;

  }

</style>

藍(lán)藍(lán)設(shè)計www.0391cbd.com )是一家專注而深入的界面設(shè)計公司,為期望卓越的國內(nèi)外企業(yè)提供卓越的UI界面設(shè)計、BS界面設(shè)計 、 cs界面設(shè)計  ipad界面設(shè)計 、 包裝設(shè)計 、 圖標(biāo)定制 、 用戶體驗(yàn) 、交互設(shè)計、 網(wǎng)站建設(shè) 、平面設(shè)計服務(wù)。

日歷

鏈接

個人資料

存檔

主站蜘蛛池模板: 国产综合另类小说色区色噜噜 | 最新国产在线| 波多野结衣中文字幕一区| 精品一区二区三区水蜜桃| 亚洲69视频| AV无码一区二区三区四区| 国产本道久久一区二区三区| 日韩午夜片| 91最新精品视频发布页| 狠狠v日韩v欧美v| 欧美黄网站免费观看| 风韵丰满熟妇啪啪区老熟熟女| 999国内精品视频免费| 日本免费福利视频| 久久成人免费| 伊人久久青草青青综合| 国产成人凹凸视频在线| 婷婷色婷婷| AV无码国产在线看岛国岛| 日本三级黄在线观看| 国产激爽爽爽大片在线观看| 99热国产在线精品99| 在线日本国产成人免费的| 在线国产综合一区二区三区| 99青青青精品视频在线| 亚洲AV无码乱码在线观看代蜜桃| 成人亚洲视频| 欧美精品亚洲精品日韩专区| 五月天天天色| 久久天天躁狠狠躁夜夜2020一| 国产网友愉拍精品| 国产成人三级| 欧美中文一区| 国产成人a在线观看视频| 91高清在线视频| 欧美黄网在线| 黄色片中文字幕| 免费a在线观看播放| 精品久久久无码专区中文字幕| 久久精品丝袜高跟鞋| 免费不卡视频| 视频在线观看一区二区| 国产在线拍偷自揄观看视频网站| 国产极品美女在线| 人妻出轨无码中文一区二区| 国产成熟女人性满足视频| 一级毛片高清| 国产欧美日韩免费| 在线免费不卡视频| 国产福利拍拍拍| 狠狠做深爱婷婷久久一区| 国产91无码福利在线| 国产呦精品一区二区三区下载| 久久不卡精品| 久久精品国产国语对白| 午夜视频免费一区二区在线看| 香蕉精品在线| 久久午夜夜伦鲁鲁片无码免费| 久草视频精品| 97se亚洲综合不卡| 亚洲天堂视频网站| 亚洲美女一区二区三区| 五月婷婷导航| 国内精品视频| 最新亚洲av女人的天堂| 亚洲精品第一页不卡| 成人永久免费A∨一级在线播放| 日韩在线观看网站| 久草青青在线视频| 国产成人精品视频一区二区电影 | a在线观看免费| 精品少妇人妻无码久久| 五月激激激综合网色播免费| 精品国产美女福到在线直播| 精品一区二区三区中文字幕| 免费激情网站| 国内精品视频在线| 国产精品免费入口视频| 九九九精品视频| 久久99国产综合精品女同| 成人91在线| 国产日韩欧美在线播放|