随笔分类 - vue2
摘要:前后端分离使用后端接口时需要配置代理跨域,通常在vue.config.js中配置, 详细信息可在浏览器搜索webpack中的devServer进行借鉴 devServer: { port: port, open: true, overlay: { warnings: false, errors: t
阅读全文
摘要:步骤1:配置jsconfig.js 位置:项目根目录/jsconfig.js { "compilerOptions": { "baseUrl": "./", "paths": { "@/*": ["src/*"] } }, // @ 不能在以下目录的文件中使用 "exclude": ["node_m
阅读全文
摘要:之前ui 给pc端的设计稿是 1920* 1080 ,并没有提过要写移动端网站,所以之前一直做的是pc端。 1,安装 flexible和 postcss-px2rem(命令行安装)npm install lib-flexible --save npm install postcss-px2rem -
阅读全文
摘要:安装依赖 cnpm install --save vuex 在src目录下新建一个store文件夹,文件夹内放置一个index.js文件,引入vue,vuex,使用插件 在main.js里引入store,需要全局挂载 1 import Vue from 'vue' 2 import App from
阅读全文
摘要:安装依赖 cnpm install --save nprogress 1 import axios from "axios"; 2 3 // 引入进度条 4 import nprogress from 'nprogress'; 5 // 引入进度条css样式 6 import "nprogress/
阅读全文
摘要:在vue.config.js里写代码解决跨域问题 1 module.exports={ 2 productionSourceMap:false, 3 // 关闭eslint 4 lintOnSave:false, 5 //配置代理跨域 6 devServer:{ 7 proxy:{ 8 "/api"
阅读全文
摘要:1 // 对axios进行二次封装 2 import axios from "axios" 3 // 利用axios对象的create方法,去创建一个axios实例 4 // request就是axios,只不过稍微配置了一下 5 const requests = axios.create({ 6
阅读全文
摘要:第一步:给需要注册的全局组件取个name 1 <script> 2 export default { 3 name: "TypeNav" 4 } 5 </script> 第二部在main.js里引入 1 // 三级联动路由组件 2 import TypeNav from '@/pages/Home/
阅读全文
摘要:在router.js里书写代码 1 let originPush = VueRouter.prototype.push; 2 let originReplace = VueRouter.prototype.replace; 3 //VueRouter.prototype原型对象添加一个方法 4 //
阅读全文
摘要:1 methods: { 2 //搜索按钮的回调 3 goSearch() { 4 //路由的跳转,采用的是编程式导航. 5 //路由传递参数 6 7 //第一种传递query参数 8 // this.$router.push({path:'/search',query:{keyword:this.
阅读全文
摘要:1 import Vue from 'vue' 2 import VueRouter from 'vue-router' 3 4 import Login from "@/pages/Login/Login"; 5 import Search from "@/pages/Search/Search"
阅读全文
摘要:通常用编程式路由进行传参 首先在router.js路由中进行占位 1 // /:keyword需要先占位 2 { 3 path:'/Search/:keyword', 4 component:Search, 5 name:"Search", 6 meta:{show: true} 7 }, 路由传参
阅读全文
浙公网安备 33010602011771号