vue mint-uiプロジェクトのよくあるエラーの問題と解決方法

15152 ワード

Use

npm install -g vue-cli

vue init webpack projectname

テスト時:
npm run dev

梱包時:
npm run build

vue-router
1、Routerがvue-cliで作成した初期テンプレートを構成する.vue-routerはなく、cnpmでインストールする必要がある.
cnpm i vue-router -D

2、router.jsに必要なコンポーネントを導入しroutersオブジェクトを作成する
import Vue from 'vue'
import Router from 'vue-router'
import StartPage from '@/components/StartPage'
import Index from '@/components/Index'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'StartPage',
      component: StartPage
    },
    {
      path: '/index',
      name: 'Index',
      component: Index
    }
  ]
})

3、ルート使用
  • マッピングルーティングを使用
  •  <router-link to="/index"></router-link>
  • プログラミングナビゲーション
  • //    
    this.$router.push('/home/first')
    
    //   
    this.$router.push({ path: '/home/first' })
    
    //      
    this.$router.push({ name: 'home', params: { userId: wise }})

    Notice
    1 . scopedを加えると、cssはコンポーネントでのみ有効になります.