vue project file main.js

1. doing?

  • Vue is initialized instance and use plug-ins required
  • And your content will render to the main page
  • It is the entry file of your project
  • It is time to execute your main.js from top to bottom of execution

2. Initial Introduction


import Vue from 'vue' // 引入VUE核心库

import App from './App.vue'  // 引入一个当前目录下的名字为App.vue的组件

Vue.config.productionTip = false;  // 是否要在生产环境当中给予提示功能。

new Vue({  // 生成一个VUE实例

  render: function (h) { return h(App) },  // 渲染函数,将组件App渲染到挂载的元素上。
  
}).$mount('#app')  //这个 #app 是挂载在 public 主页面上的,你打开index 就会看到 这个元素 id

3. Use of plug-ins

Here to introduce vuex

  • First we have to download plug-good vuex
  • vuex introductory article, we are interested can look at
  • Then is initialized vuex, vuex is to add to my project in the past, you also need to reference light installed in order to use it
  • Of course, the new project is created automatically when introduced, but when to introduce our newly added their own

Here Insert Picture Description

  • You can see the picture there is a white square
  • I use it to print it and see what we have in the end is introduced

Here Insert Picture Description


  • We can see the content delivery has passed all the contents of your vuex
  • We can put the entire page compared to a stage, and each page is the top performer
  • Here it is passed to the stage, and then all pages can be used
  • If you do not pass, you call is a call not vuex inside data

Since the vuex passed over, then I can use the page
when I print the App.vue this instance App.vue page

/-----------------App.vue------------------------/
<script>
export default {
  mounted(){
    console.log(this)
  }
}
</script>

Here Insert Picture Description

  • The result is undoubtedly very long, but we can find $ store inside
  • And to see our data in it
  • So that we can call it a
Published 63 original articles · won praise 6 · views 1196

Guess you like

Origin blog.csdn.net/qq_44163269/article/details/105227457