vue的main.js
import Vue from 'vue'; import App from './App.vue'; //================http 请求===========================// import request from './lib/request/request';
Vue.prototype.$request = request; //=======================饿了么UI===================//
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
Vue.use(ElementUI) //==============路由配置======================//
import Router from 'vue-router'
import header from './components/header/header.vue'
import menu from './components/menu/menu.vue'
import child from './components/headerchild/headerchild.vue';
Vue.use(Router);
const routerArr=[
{
path:'/',
component:header
},
{
path:'/header',
component:header,
children:[
{
path:'child',
component:child
},
]
},
]; let router=new Router({
mode:'history',
routes:routerArr
}); //================vuex=======================//
import Vuex from 'vuex'
Vue.use(Vuex);
let store=new Vuex.Store({
state:{
totalPrice:0
},
mutations:{
increase(state,price){
state.totalPrice+=price;
},
decrease(state,price){
state.totalPrice-=price;
}
},
actions:{ //和后端交互,异步
increa(context,id){
/* api(xxx,function () {
context.commit('increase',id);
})*/ }
}
})
//this.$store.state.totalPrice 获得数据
//this.$store.commit('decrease',5); 执行mutation方法,不能直接和后端交互
//this.$store.dispatch('decrease',5); 执行actions方法,和后端异步交互,再执行mutation //================实例化对象=======================// /* eslint-disable no-new */
new Vue({
el: '#app',
router,
store,
render: h => h(App)
});
vue的main.js的更多相关文章
- vue项目中主要文件的加载顺序(index.html、App.vue、main.js)
先后顺序: index.html > App.vue的export外的js代码 > main.js > App.vue的export里面的js代码 > Index.vue的ex ...
- 关于Vue中main.js,App.vue,index.html之间关系进行总结
在初始化的Vue项目中,我们最先接触到的就是main.js,App.vue,index.html这三个文件,我们从培训视频或者官方文档上可以了解到: index.html---主页,项目入口 App. ...
- vue在main.js中全局引用css的方法及坑
步骤: 1.配置文件webpack.config.js: { test:/\.css$/, loader:'style-loader!css-loader' } 坑1:-loader尾缀 坑2:Mod ...
- vue 在main.js里使用vue实例
可以用 Vue.prototype 比如 Vue.prototype.$indicator.close(); 关闭正在加载的动画
- vue中main.js配置后端请求地址
Vue.config.productionTip = false; axios.defaults.baseURL = 'http://127.0.0.1:8003/';//后端开发环境地址 // ax ...
- 用vue开发一个app(2,main.js)
昨天跟着vue的官网搭建了vue的一个脚手架,我也是第一次用VUE一切都在摸索阶段. 今天试着看下里面脚手架里面有点什么东西 先看看main.js 导入了3个模块 一个vue,一个app,还有rout ...
- Vue main.js 文件中全局组件注册部分
在 \src\components\index.js 文件中export组件 import HeaderList from './HeaderList' import HeaderMenu from ...
- 【vue】index.html main.js app.vue index.js怎么结合的? 怎么打包的?搜集的信息
转载:https://blog.csdn.net/yudiandemingzi/article/details/80247137 怎么结合的: 一.启动项目 第一步:cmd进入项目文件里,运行npm ...
- vue项目中,main.js,App.vue,index.html如何调用
1.main.js是我们的入口文件,主要作用是初始化vue实例,并引入所需要的插件 2.App.vue是我们的主组件,所有页面都是在App.vue下进行切换的.其实你也可以理解为所有的路由也是App. ...
随机推荐
- 详解MessageBox(),MsgBox函数的正确使用
//或者使用chr(13),chr(10)效果一样 MsgBox "a"&chr(13)&"b"&chr(10)&"c ...
- [异常笔记] spring boot 启动-2018040201
异常 1.编码引发异常 00:59:49.311 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - ...
- python3.X中pickle类的用法(cPickle模块移除了)
1.python3.x中移除了cPickle模块,可以使用pickle模块代替.最终我们将会有一个透明高效的模块. 2.因为存储的是对象,必须使用二进制形式写进文件 #!/usr/bin/python ...
- Lucene简单总结
Lucene API Document Document:文档对象,是一条原始数据 文档编号 文档内容 1 谷歌地图之父跳槽FaceBook 2 谷歌地图之父加盟FaceBook 3 谷歌地图创始人拉 ...
- Python9-数据类型-day3
数据类型转换 #int----->str s = 1 i = str(s) print(i) #str----->int s = ' i = int(s) print(i) #int--- ...
- 两种查看SIP版本的方法python
第一种:进入python命令行 print(sip.SIP_VERSION_STR) 注意对应的PyQt版本号和大小写 print(PyQt5.sip.SIP_VERSION_STR) 第二种:直接在 ...
- GDOI--DAY2 游记
今天,熬夜不够多,果然,不出所料,爆零了... 第一题,看到数据之大,懵逼了,于是,敲了个二分SPFA,但是!最大的点GG了,呜呜~~~~(>_<)~~~~ ,于是,就不继续做第一题了(虽 ...
- Httpclient httpdelete 参数
Httpclient 中常用的请求有2个,HttpPost 和 HttpGet,今天在对某个网站进行分析的时候,突然发现用到了 HttpDelete,并且传参 是 Json. 1.一般 HttpPos ...
- USACO Section2.2 Preface Numbering 解题报告 【icedream61】
preface解题报告----------------------------------------------------------------------------------------- ...
- python利用PIL库使图片高斯模糊
一.安装PIL PIL是Python Imaging Library简称,用于处理图片.PIL中已经有图片高斯模糊处理类,但有个bug(目前最新的1.1.7bug还存在),就是模糊半径写死的是2,不能 ...