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的更多相关文章

  1. vue项目中主要文件的加载顺序(index.html、App.vue、main.js)

    先后顺序: index.html > App.vue的export外的js代码 > main.js > App.vue的export里面的js代码 > Index.vue的ex ...

  2. 关于Vue中main.js,App.vue,index.html之间关系进行总结

    在初始化的Vue项目中,我们最先接触到的就是main.js,App.vue,index.html这三个文件,我们从培训视频或者官方文档上可以了解到: index.html---主页,项目入口 App. ...

  3. vue在main.js中全局引用css的方法及坑

    步骤: 1.配置文件webpack.config.js: { test:/\.css$/, loader:'style-loader!css-loader' } 坑1:-loader尾缀 坑2:Mod ...

  4. vue 在main.js里使用vue实例

    可以用 Vue.prototype 比如 Vue.prototype.$indicator.close(); 关闭正在加载的动画

  5. vue中main.js配置后端请求地址

    Vue.config.productionTip = false; axios.defaults.baseURL = 'http://127.0.0.1:8003/';//后端开发环境地址 // ax ...

  6. 用vue开发一个app(2,main.js)

    昨天跟着vue的官网搭建了vue的一个脚手架,我也是第一次用VUE一切都在摸索阶段. 今天试着看下里面脚手架里面有点什么东西 先看看main.js 导入了3个模块 一个vue,一个app,还有rout ...

  7. Vue main.js 文件中全局组件注册部分

    在 \src\components\index.js 文件中export组件 import HeaderList from './HeaderList' import HeaderMenu from ...

  8. 【vue】index.html main.js app.vue index.js怎么结合的? 怎么打包的?搜集的信息

    转载:https://blog.csdn.net/yudiandemingzi/article/details/80247137 怎么结合的: 一.启动项目 第一步:cmd进入项目文件里,运行npm ...

  9. vue项目中,main.js,App.vue,index.html如何调用

    1.main.js是我们的入口文件,主要作用是初始化vue实例,并引入所需要的插件 2.App.vue是我们的主组件,所有页面都是在App.vue下进行切换的.其实你也可以理解为所有的路由也是App. ...

随机推荐

  1. Windows Server 2012 搭建DHCP及远程路由访问

    1.1    基础环境信息 1.2    DHCP与远程访问服务器角色安装 1.服务器管理器—>仪表板—>添加角色和功能,出现添加角色和功能向导,点击下一步 2.选择安装类型为基于角色或基 ...

  2. Redis 持久化操作

    hash类型 类比:mysql数据库存储数据 持久化操作 以本身的数据以文件形式保存到硬盘中 手动快照持久化 i 备份机制(频率) vi redis.conf save 900 1  900s如果一个 ...

  3. <Docker学习>4. docker容器的使用

    简单的说, 容器是独立运行的一个或一组应用, 以及它们的运行态环境. 对应的, 虚拟机可以理解为模拟运行的一整套操作系统( 提供了运行态环境和其他系统环境) 和跑在上面的应用.容器的运行是基于镜像的. ...

  4. python语法练习题之九九乘法表

    九九乘法表 for...in方法实现 # 方法一 for i in range(1, 10): for j in range(1, i+1): print('{}*{}={:<4}'.forma ...

  5. [BZOJ2734][HNOI2012] 集合选数(状态压缩+思维)

    Description 题目链接 Solution 可以根据条件构造出一个矩阵, 1 3 9 27 81... 2 6 18.... 4 12 36... 这个矩阵满足\(G[i][1]=G[i-1] ...

  6. [Bzoj2282]消防(二分答案+树的直径)

    Description 某个国家有n个城市,这n个城市中任意两个都连通且有唯一一条路径,每条连通两个城市的道路的长度为zi(zi<=1000). 这个国家的人对火焰有超越宇宙的热情,所以这个国家 ...

  7. 17-比赛1 D - IPC Trainers (贪心 + 优先队列)

    题目描述 本次印度编程训练营(Indian Programming Camp,IPC)共请到了 N 名教练.训练营的日程安排有 M 天,每天最多上一节课.第 i 名教练在第 Di 天到达,直到训练营结 ...

  8. Gold Balanced Lineup POJ - 3274

    Description Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been abl ...

  9. Evevt Loop、任务队列、定时器等

    上周五,一个朋友发给我一道面试题,代码如下: console.log(1); setTimeout(console.log(2), 0); Promise.resolve().then(res =&g ...

  10. 奇异值分解(SVD)原理详解及推导

    在网上看到有很多文章介绍SVD的,讲的也都不错,但是感觉还是有需要补充的,特别是关于矩阵和映射之间的对应关系.前段时间看了国外的一篇文章,叫A Singularly Valuable Decompos ...