1.安装
成都创新互联 服务项目包括临川网站建设、临川网站制作 、临川网页制作以及临川网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,临川网站推广 取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到临川省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
Vue CLI 的包名称由 vue-cli 改成了 @vue/cli。 如果你已经全局安装了旧版本的 vue-cli (1.x 或 2.x),你需要先通过以下方式先卸载它:
npm uninstall vue-cli -g
# 或
yarn global remove vue-cli vue-cli 3.x安装:
npm install -g @vue/cli
# OR
yarn global add @vue/cli 说明:-g / global 表示全局安装。
安装完成后可通过以下代码校验安装是否成功:
2.创建项目
2.1vue create xxx
vue create my-project
# OR
vue ui 按键盘上下键可以选择默认(default)还是手动(Manually),如果选择default,一路回车执行下去就行了
继续手动一下
2.2若你之前未保存过preset,或若不使用之前保存的preset创建项目,你会被提示选取一个 preset。你可以选默认的包含了基本的 Babel + ESLint 设置的 preset,也可以选“Munually select features”即“手动选择特性”来选取需要的特性,如下图所示。一般会选择手动选择特性。
选择之后会出现如下界面:
选择配置,看个人项目需求
注意,空格键是选中与取消,A键是全选
Babel —— ES6转换器
这个是解析我们es6的代码的,因为对于一些低版本的ie浏览器,还不能识别es6代码,那么vue里面好多要去写es6的代码,这个时候我们就可以用babel这个工具将es6的代码转译成浏览器能识别的代码。
TypeScript —— 使用JS的超类语言TS
Progressive Web App Support —— PWA单页应用
Router —— 使用路由管理器
Vuex —— 使用 vue 状态管理器
CSS Pre-processors —— CSS预处理
Linter / Formatter —— Eslint 安装
Unit Testing —— 单元测试
E2E Testing —— 单元测试
可以根据自己的需求,选择配置,小颖是这么选的:
选完之后回车
2.3是否使用路由的 history模式,选择 yes
2.4 选择css预处理器,请根据个人情况进行选择,这里我选择的是 Sass/SCSS < with dart-sass>
2.5 选择 Eslint 的使用方式,我选择的 ESLint + Prettier
2.6 选择语法检查方式,我自己选择保存就检测
第一个是保存检测,第二个是fix和commit的时候检测
2.7选择以上的配置文件放置的位置,把babel,postcss,eslint这些配置文件放哪,这里随便选,我选择放在独立文件夹
2.8 是否保存以上的 preset 配置,可在将来创建项目的时候直接引用,我选择no
键入N不记录,如果键入Y需要输入保存名字
确定后,等待下载依赖模块
3.启动项目
初始完之后,进入到项目根目录: cd my-project
启动项目:npm run serve
在浏览器输入 http://localhost:8080就可以看到vue的欢迎界面
4.打包上线
vue-cli 也提供了打包的命令,在项目根目录下执行: npm run build 执行完之后,可以看到在项目根目录下多出了一个 dist 目录,该目录下就是打包好的所有静态资源,直接部署到静态资源服务器 就好了。
注意:
参考: vue.config.js常用配置
使用vue-cli3.0搭建项目比之前更简洁,没有了build和config文件夹。
vue-cli3的一些服务配置都迁移到CLI Service里面了,对于一些基础配置和一些扩展配置需要在根目录新建一个vue.config.js文件进行配置
module.exports = {
// 选项...
} 基本路径
baseUrl从 Vue CLI 3.3 起已弃用使用publicPath来替代。
在开发环境下,如果想把开发服务器架设在根路径,可以使用一个条件式的值
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/production-sub-path/' : '/'
} 构建输出目录(打包位置)
outputDir
当运行 vue-cli-service build 时生成的生产环境构建文件的目录
module.exports = {
outputDir: 'dist',
} 静态资源目录
assetsDir
放置生成的静态资源 (js、css、img、fonts) 的目录
module.exports = {
assetsDir: 'assets',
} eslint代码检测
是否开启eslint保存检测,有效值:ture | false | 'error'
设置为 true 时, eslint-loader 会将 lint 错误输出为编译警告。默认情况下,警告仅仅会被输出到命令行,且不会使得编译失败
希望让 lint 错误在开发时直接显示在浏览器中,可以使用 lintOnSave: 'error' 。这会强制 eslint-loader 将 lint 错误输出为编译错误
webpack-dev-server 相关配置
devServer: {
open: true,//设置自动打开
port: 1880,//设置端口
proxy: {
//设置代理
'/axios': {
target: 'http://101.15.22.98',
changeOrigin: true,
secure: false, //如果是http接口,需要配置该参数
pathRewrite: {
'^/axios': ''
}
}
}
}
} module.exports = {
// 部署应用时的基本 URL
publicPath: process.env.NODE_ENV === 'production' ? '192.168.60.110:8080' : '192.168.60.110:8080',
// build时构建文件的目录 构建时传入 --no-clean 可关闭该行为
outputDir: 'dist',
// build时放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录
assetsDir: '',
// 指定生成的 index.html 的输出路径 (相对于 outputDir)。也可以是一个绝对路径。
indexPath: 'index.html',
// 默认在生成的静态资源文件名中包含hash以控制缓存
filenameHashing: true,
// 构建多页面应用,页面的配置
pages: {
index: {
// page 的入口
entry: 'src/index/main.js',
// 模板来源
template: 'public/index.html',
// 在 dist/index.html 的输出
filename: 'index.html',
// 当使用 title 选项时,
// template 中的 title 标签需要是 <%= htmlWebpackPlugin.options.title %>
title: 'Index Page',
// 在这个页面中包含的块,默认情况下会包含
// 提取出来的通用 chunk 和 vendor chunk。
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
// 当使用只有入口的字符串格式时,
// 模板会被推导为 `public/subpage.html`
// 并且如果找不到的话,就回退到 `public/index.html`。
// 输出文件名会被推导为 `subpage.html`。
subpage: 'src/subpage/main.js'
},
// 是否在开发环境下通过 eslint-loader 在每次保存时 lint 代码 (在生产构建时禁用 eslint-loader)
lintOnSave: process.env.NODE_ENV !== 'production',
// 是否使用包含运行时编译器的 Vue 构建版本
runtimeCompiler: false,
// Babel 显式转译列表
transpileDependencies: [],
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建
productionSourceMap: true,
// 设置生成的 HTML 中 和
基本
文件
流程
错误
SQL
调试
请求信息 : 2026-06-03 00:31:01 HTTP/1.1 GET : /article/gcioej.html 运行时间 : 0.6891s ( Load:0.0062s Init:0.0011s Exec:0.6726s Template:0.0091s ) 吞吐率 : 1.45req/s 内存开销 : 2,246.37 kb 查询信息 : 12 queries 5 writes 文件加载 : 36 缓存信息 : 0 gets 0 writes 配置加载 : 130 会话信息 : SESSION_ID=57ll8s6hhev34hg9qfi9v7pn63
/www/wwwroot/tsicrk.com/index.php ( 1.09 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/ThinkPHP.php ( 4.61 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Think.class.php ( 12.26 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Storage.class.php ( 1.37 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Storage/Driver/File.class.php ( 3.52 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Mode/common.php ( 2.82 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Common/functions.php ( 53.56 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Hook.class.php ( 4.01 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/App.class.php ( 13.49 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Dispatcher.class.php ( 14.79 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Route.class.php ( 13.36 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Controller.class.php ( 11.23 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/View.class.php ( 7.59 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php ( 3.68 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php ( 3.88 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php ( 1.91 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Conf/convention.php ( 11.15 KB ) /www/wwwroot/tsicrk.com/App/Common/Conf/config.php ( 2.14 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Lang/zh-cn.php ( 2.55 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Conf/debug.php ( 1.49 KB ) /www/wwwroot/tsicrk.com/App/Home/Conf/config.php ( 0.31 KB ) /www/wwwroot/tsicrk.com/App/Home/Common/function.php ( 3.33 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php ( 5.62 KB ) /www/wwwroot/tsicrk.com/App/Home/Controller/ArticleController.class.php ( 6.02 KB ) /www/wwwroot/tsicrk.com/App/Home/Controller/CommController.class.php ( 1.60 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Model.class.php ( 60.11 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php ( 32.43 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php ( 16.74 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Cache.class.php ( 3.83 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Cache/Driver/File.class.php ( 5.87 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template.class.php ( 28.16 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php ( 22.40 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template/TagLib.class.php ( 9.16 KB ) /www/wwwroot/tsicrk.com/App/Runtime/Cache/Home/7540f392f42b28b481b30614275e4e55.php ( 17.71 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php ( 0.97 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php ( 5.24 KB )
[ app_init ] --START-- Run Behavior\BuildLiteBehavior [ RunTime:0.000005s ] [ app_init ] --END-- [ RunTime:0.000030s ] [ app_begin ] --START-- Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000291s ] [ app_begin ] --END-- [ RunTime:0.000311s ] [ view_parse ] --START-- [ template_filter ] --START-- Run Behavior\ContentReplaceBehavior [ RunTime:0.000051s ] [ template_filter ] --END-- [ RunTime:0.000072s ] Run Behavior\ParseTemplateBehavior [ RunTime:0.006110s ] [ view_parse ] --END-- [ RunTime:0.006139s ] [ view_filter ] --START-- Run Behavior\WriteHtmlCacheBehavior [ RunTime:0.000156s ] [ view_filter ] --END-- [ RunTime:0.000171s ] [ app_end ] --START--
1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`pid`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( pid= ) [8] Undefined index: pid /www/wwwroot/tsicrk.com/App/Home/Controller/ArticleController.class.php 第 47 行. [8] Undefined index: db_host /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 120 行. [8] Undefined index: db_port /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 121 行. [8] Undefined index: db_name /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 122 行.
0.6891s