关于vue的常识问题及解决方法

前端之家收集整理的这篇文章主要介绍了关于vue的常识问题及解决方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@H_403_0@<span style="font-size: 18px">一.<span style="font-size: 18px">VSCode开发必备插件


@H_4030@1.<span class="name clickable" title="扩展名">Beautify:语法高亮;


@H
4030@<span class="name clickable" title="扩展名">2.Bracket Pair Colorizer :对括号对进行着色;


@H
403_0@<span class="name clickable" title="扩展名">3.<span class="name clickable" title="扩展名">ESLint:ESLint插件,高亮提示


@H_403_0@<span class="name clickable" title="扩展名">4.HTML CSS Support:css提示支持vue);


@H_403_0@<span class="name clickable" title="扩展名">5.HTML Snippets:自动帮你输入HTML标签


@H_4030@<span class="name clickable" title="扩展名">6.veter:目前比较好的Vue语法高亮;


@H
403_0@<span class="name clickable" title="扩展名">7.<span class="name clickable" title="扩展名">vscode-icons:文件图标,方便定位文件


@H_403_0@<span class="name clickable" title="扩展名"><span class="name clickable" title="扩展名">8.<span class="name clickable" title="扩展名">Vue 2 Snippets:API添加代码片段;

@H_403_0@<span class="name clickable" style="font-size: 18px" title="扩展名"><span class="name clickable" title="扩展名"><span class="name clickable" title="扩展名">二.页面文件路由跳转文件配置


@H_403_0@<span class="name clickable" style="font-size: 16px" title="扩展名"><span class="name clickable" title="扩展名"><span class="name clickable" title="扩展名">文件在router文件夹下的index.js下

import index from '@/components/pages/My/index'
......
routes: [
{
path:'/index',
name:'index',
component:index
}
]
@H_403_0@

@H_403_0@解决方法

@H_403_0@文件在config文件夹下的index.js下

module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': {
target:'http://192.168.1.240:18080',
changeOrigin: true,
     }
}
},
......
 
 
 
文件端口可能会进行更改,使用在全局里面设置端口,在分页面进行引用;
 
文件
//main.js
import global from './components/global/global';
Vue.prototype.GLOBAL = global;
 
//global.vue
 
//页面引用接口写法
method:'post',
url:this.GLOBAL.proxy+'/app/course/study.do?courseId='+this.courseId+'&userId='+this.GLOBAL.userId,
 
 
 
@H_403_0@:基于 Promise,用于浏览器和 nodejs 的与服务器端通信库。

@H_403_0@:npm install axios --save;

@H_403_0@

@H_4030@<span style="font-size: 18px">六.vuex的安装使用


@H
4030@<span style="font-size: 16px">1.在项目里安装vux


@H
4030@<span style="font-size: 18px"><span style="font-size: 14px">npm install vux --save;


@H
403_0@<span style="font-size: 16px">2.安装vux-loader (这个vux文档似乎没介绍,当初没安装结果报了一堆错误


@H_4030@<span style="font-size: 18px"><span style="font-size: 14px">npm install vux-loader --save-dev


@H
4030@<span style="font-size: 16px">3.安装less-loader  (这个是用以正确编译less源码,否则会出现 ' Cannot GET / ')


@H
4030@<span style="font-size: 18px"><span style="font-size: 14px">npm install less less-loader --save-dev


@H
403_0@<span style="font-size: 16px">4.安装yaml-loader  (以正确进行语言文件读取,我没安装似乎也没报错)


@H_4030@<span style="font-size: 18px"><span style="font-size: 14px">npm install yaml-loader --save-dev


@H
403_0@<span style="font-size: 16px">5.在build/webpack.base.conf.js 文件进行配置、

'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
return path.join(__dirname,'..',dir)
}
//vux的相关配置
const vuxLoader = require('vux-loader')
 
let webpackConfig = {
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js','.vue','.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'),resolve('test'),resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}
//这个必须放在下面
module.exports = vuxLoader.merge(webpackConfig,{
plugins: ['vux-ui','progress-bar','duplicate-style']
})
 
自带的样式,记得添加
 
 
 
七.公用顶部导航栏组件
 
 
Box;
Box-orient: vertical;
 
页面
 
 
标题栏
 
 

@H_4030@<span class="name clickable" style="font-size: 18px" title="扩展名"><span class="name clickable" title="扩展名"><span class="name clickable" title="扩展名"> 


@H
4030@<span class="name clickable" style='cursor: pointer; font-size: 26px; line-height: 30px; font-weight: 600; white-space: nowrap; color: #cccccc; font-family: -apple-system,BlinkMacSystemFont,"Segoe WPC","Segoe UI",HelveticaNeue-Light,"Noto Sans","Microsoft YaHei","PingFang SC","Hiragino Sans GB","Source Han Sans SC","Source Han Sans CN","Source Han Sans",sans-serif; background-color: #1e1e1e' title="扩展名"> 


@H
403_0@<span class="name clickable" style='cursor: pointer; font-size: 26px; line-height: 30px; font-weight: 600; white-space: nowrap; color: #cccccc; font-family: -apple-system,sans-serif; background-color: #1e1e1e' title="扩展名"> 

猜你在找的Vue相关文章