记录
一级目录
路由history模式下
const router = new VueRouter({
// 可以在切换路由时回到顶部
scrollBehavior: () => ({ x: 0, y: 0 }),
mode: 'history',
base: process.env.BASE_URL,
routes: [...routes, ...routerMap],
});
webpack之proxyTable设置跨域
proxyTable: {
'/api': {
target: 'http://www.zj.com/', // 接口域名
changeOrigin: true, // 是否跨域
pathRewrite: {
'^/api': '/index/index', // 需要rewrite重写
},
},
},
aynsc 返回一个promise对象,返回promise对象本身
一些配置
/* prettier的配置 */
{
// 超过最大值换行
"printWidth": 120,
// 缩进字节数
"tabWidth": 2,
// 缩进不使用tab,使用空格
"useTabs": false,
// 句尾添加分号
"semi": true,
// 使用单引号代替双引号
"singleQuote": true,
// 默认值。因为使用了一些折行敏感型的渲染器(如GitHub comment)而按照markdown文本样式进行折行
"proseWrap": "preserve",
// (x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号
"arrowParens": "avoid",
// 在对象,数组括号与文字之间加空格 "{ foo: bar }"
"bracketSpacing": true,
// 不格式化vue文件,vue文件的格式化单独设置
"disableLanguages": ["vue"],
// 结尾是 \n \r \n\r auto
"endOfLine": "auto",
//不让prettier使用eslint的代码格式进行校验
"eslintIntegration": false,
"htmlWhitespaceSensitivity": "ignore",
// 不使用prettier格式化的文件填写在项目的.prettierignore文件中
"ignorePath": ".prettierignore",
// 在jsx中把'>' 是否单独放一行
"jsxBracketSameLine": false,
// 在jsx中使用单引号代替双引号
"jsxSingleQuote": false,
// 格式化的解析器,默认是babylon
"parser": "babylon",
// Require a 'prettierconfig' to format prettier
"requireConfig": false,
//不让prettier使用stylelint的代码格式进行校验
"stylelintIntegration": false,
// 在对象或数组最后一个元素后面是否加逗号(在ES5中加尾逗号)
"trailingComma": "es5",
// 不让prettier使用tslint的代码格式进行校验
"tslintIntegration": false
}
vue路由跳转报错路由重复 Avoided redundant navigation to current location
const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
return VueRouterPush.call(this, to).catch((err) => err);
};
van-button阻止冒泡
https://github.com/youzan/vant-weapp/issues/3473