首先安装 less 和 less-loader ,在项目目录下运行以下命令javascript
# npm安装 $ npm install less less-loader --save-dev # 或者使用 yarn $ yarn add less less-loader --dev
build/webpack.base.conf.js
,在 module.exports = 的对象的 module.rules 后面添加一段:module.exports = { // 此处省略无数行,已有的的其余的内容 module: { rules: [ // 此处省略无数行,已有的的其余的规则 { test: /\.less$/, loader: "style-loader!css-loader!less-loader", } ] } }
<style scoped lang="less"> </style>
#/
给去掉const router = new VueRouter({
mode: 'hash',
routes
});
// 去掉路由中自带的 #/ 这种东西 mode: 'history',
history
以后须要在服务器部署时增长一些配置,具体方法插件下面官方写的配置方法 文档连接 https://router.vuejs.org/zh/guide/essentials/history-mode.html#%E5%90%8E%E7%AB%AF%E9%85%8D%E7%BD%AE%E4%BE%8B%E5%AD%90

npm install jquery --save
main.js中
或者css
main.js中html
:class="{'想要改变的类名': 判断条件}/
this.$router.push({
path: '/setPayPwd',
query: {
forgetPassword: 1
}
})
行内
npm install vuex --save
import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); let store = new Vuex.Store({ state: { formData: {} // 企业提交数据表单对象 } }); export default store;
在main.js实例化对象时中添加
watch: {
'$route' (to, from) { // 检测路由改变 header 内容 if (to.name === 'Index') { this.$store.state.PageTitle = '预定领号'; this.$store.state.isShowBack = false; } else if (to.name === 'PreferentialDescription') { this.$store.state.PageTitle = '优惠说明'; this.$store.state.isShowBack = true; } else if (to.name === 'RuleIntroduction') { this.$store.state.PageTitle = '规则简介'; this.$store.state.isShowBack = true; } else if (to.name === 'ReservationSuccess') { this.$store.state.PageTitle = '预定排号'; this.$store.state.isShowBack = true; } } }
vue
挂载全局方法main.js
文件进行编辑,这里以 axios
为例演示import Vue from 'vue' import axios from 'axios' Vue.prototype.axios = axios
.vue
文件的 sccript
中以下编辑Vue.axios.post('url', { name: '' }) .then(response => { console.log(response) }) .catch(response => { console.log(response) })