flask+vue2.0
1.蓝图的注册要放在所有路由之后。这个坑
2.Vue 打包不生成 .map 文件设置方法
修改config/index.js
productionSourceMap: false
3.Vue 跨域,本地调试跨域的解决方案(建立模拟服务器并从真实的服务器请求数据),如果是服务器,用ngixn配置。
修改config/index.js
proxyTable: {
'/api': {
target: 'http://zuowen.api.juhe.cn/',//
changeOrigin: true,
secure: false,// 如果是https接口,需要配置这个参数设置为true
pathRewrite: {
'^/api/v1': '/api' //重写
}
4.TTF字体,字体文件名的后缀TTF要改为小写和下面对应,并安装url-loader
build/webpack.base.conf.js
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
5.打包vue
npm run build
6.将axios设为全局
Vue.prototype.axios = axios Vue.config.productionTip = false axios.defaults.baseURL = '/api/v1/' axios.defaults.timeOut = 50000
7.其他js引用全局axios,不知道这样是不是最好的办法,暂时就这样用一下吧。
import Vue from 'vue'
Vue.prototype.axios({
url: value,
method: 'get',
params: {id: data.params.id}
})
8.去掉vue路径中#字符,修改router/index.js中mode为history
const router = new VueRouter({
mode: 'history',
routes
})

浙公网安备 33010602011771号