广告
返回顶部
首页 > 资讯 > 前端开发 > JavaScript >Vue前端框架搭建过程
  • 671
分享到

Vue前端框架搭建过程

2024-04-02 19:04:59 671人浏览 薄情痞子
摘要

目录一、安装 nodejs二、安装 Vue-cli三、创建项目一、安装 nodejs 见 windows下安装NodeJS。 二、安装 vue-cli 1.vue-cli 2.x 升

一、安装 nodejs

windows下安装NodeJS。

二、安装 vue-cli

1.vue-cli 2.x 升级到 3.x

(1)卸载 2.x 版本

npm uninstall -g vue-cli

(2)安装

npm install -g @vue/cli

(3)查看版本

vue -V
vue -V@vue/cli 5.0.8

三、创建项目

1.vue-cli 2.x 项目

(1)创建

vue init webpack test2.0
D:\test>vue init WEBpack test2.0
? Project name test2.0
? Project description A vue.js project
? Author chaoyue <chaoyue@qq.com>
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Set up unit tests No
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recommended) yarn

   vue-cli · Generated "test2.0".
# Installing project dependencies ...
# ========================

yarn install v1.22.19
info No lockfile found.
[1/5] Validating package.JSON...
[2/5] Resolving packages...
warning autoprefixer > browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning babel-core > babel-reGISter > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-core > babel-runtime > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-eslint@8.2.6: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
warning CSS-loader > cssnano > autoprefixer > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning css-loader > cssnano > postcss-merge-rules > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning css-loader > cssnano > postcss-merge-rules > caniuse-api > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning css-loader > cssnano > postcss-svGo > svgo@0.7.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
warning css-loader > cssnano > postcss-merge-rules > postcss-selector-parser > flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
warning eslint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
warning eslint-loader@1.9.0: This loader has been deprecated. Please use eslint-webpack-plugin
warning extract-text-webpack-plugin@3.0.2: Deprecated. Please use https://GitHub.com/webpack-contrib/mini-css-extract-plugin
warning html-webpack-plugin@2.30.1: out of support
warning optimize-css-assets-webpack-plugin > cssnano > cssnano-preset-default > postcss-svgo > svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
warning optimize-css-assets-webpack-plugin > cssnano > cssnano-preset-default > postcss-svgo > svgo > stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: Https://developer.mozilla.org/en-US/docs/Web/javascript/Reference/Global_Objects/Array/sort#browser_compatibility
warning uglifyjs-webpack-plugin > uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
warning webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
warning webpack > node-libs-browser > url > querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning webpack > watchpack > watchpack-chokidar2 > chokidar > braces > snapdragon > source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
warning webpack > watchpack > watchpack-chokidar2 > chokidar > braces > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning webpack > watchpack > watchpack-chokidar2 > chokidar > braces > snapdragon > source-map-resolve > source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
warning webpack > watchpack > watchpack-chokidar2 > chokidar > braces > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
warning webpack-bundle-analyzer > bfj-node4@5.3.1: Switch to the `bfj` package for fixes and new features!
warning webpack-dev-server > chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
warning webpack-dev-server > sockjs > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
success Saved lockfile.
Done in 63.15s.
Running eslint --fix to comply with chosen preset rules...
# ========================

yarn run v1.22.19
$ eslint --ext .js,.vue src --fix
Done in 8.24s.

# Project initialization finished!
# ========================

To get started:

  cd test2.0
  npm run dev

Documentation can be found at https://vuejs-templates.github.io/webpack

创建完成后,项目目录结构如下:

在这里插入图片描述

(2)启动

cd test2.0
npm install
npm run dev

在这里插入图片描述

(3)安装 vux ①不使用模板安装

npm install vux --save
npm install vux-loader --save-dev
npm install less less-loader --save-dev

修改 build\webpack.base.conf.js :

const vuxLoader = require('vux-loader')

const originalConfig = {
...

const webpackConfig = originalConfig // 原来的 module.exports 代码赋值给变量 webpackConfig

module.exports = vuxLoader.merge(webpackConfig, {
  plugins: ['vux-ui']
})

src 下创建 views 目录,新建 test.vue 文件:

<template>
  <div style="padding: 15px;">
    <button-tab>
      <button-tab-item selected>{{ today }}</button-tab-item>
      <button-tab-item>{{ week }}</button-tab-item>
      <button-tab-item>{{ month }}</button-tab-item>
    </button-tab>
  </div>
</template>

<script>
  import {ButtonTab, ButtonTabItem} from 'vux'
  export default {
    components: {
      ButtonTab,
      ButtonTabItem
    },
    data () {
      return {
        today: '今天',
        week: '本周',
        month: '本月'
      }
    }
  }
</script>

<style scoped>

</style>

配置路由 router\index.js :

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Test from '@/views/test'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/test',
      name: 'test',
      component: Test
    }
  ]
})

访问 http://localhost:8080/#/test :

在这里插入图片描述

常见错误:
1.Module build failed: TypeError: this.getOptions is not a function
解决方法:
less 和 less-loader 版本过高,安装低版本:

npm install less@3.9.0 less-loader@4.1.0 --save-dev

2.You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use to ignore all warnings in a file.
解决方法:
原因是开启了 eslint 编码规范检查,修改 build\webpack.base.conf.js ,注释掉以下一行代码:

//...(config.dev.useEslint ? [createLintingRule()] : []),

②使用模板安装

vue init airyland/vux2 test-t2.0
D:\test>vue init airyland/vux2 test-t2.0
? Project name test-t2.0
? Project description A Vue.js project
? Author chaoyue <chaoyue@qq.com>
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Setup unit tests No
? Setup e2e tests with Nightwatch? No
   vue-cli · Generated "test-t2.0".
   To get started:
     cd test-t2.0
     npm install
     npm run dev
   Documentation can be found at https://vuejs-templates.github.io/webpack

官网模板的路由是以常量的形式写在 main.js 中,我们改造到 router/index.js 中去:
修改 main.js:

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import router from './router'
// import VueRouter from 'vue-router'
import App from './App'
// import Home from './components/HelloFromVux'
//
// Vue.use(VueRouter)
//
// const routes = [{
//   path: '/',
//   component: Home
// }]
//
// const router = new VueRouter({
//   routes
// })

FastClick.attach(document.body)

Vue.config.productionTip = false


new Vue({
  router,
  render: h => h(App)
}).$mount('#app-box')

修改 index.js:

import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
import Hello from '@/components/HelloFromVux'
import Test from '@/views/test'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Hello',
      component: Hello
    },
    {
      path: '/test',
      name: 'test',
      component: Test
    }
  ]
})

启动:

cd test-t2.0
npm install
npm run dev

访问 http://localhost:8080/

在这里插入图片描述

(4)安装 axiOS

npm install axios --save-dev

(5)安装 vuex

npm install vuex --save-dev

2.vue-cli 3.x 项目

(1)创建

vue create test

到此这篇关于Vue前端框架搭建的文章就介绍到这了,更多相关Vue框架搭建内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: Vue前端框架搭建过程

本文链接: https://www.lsjlt.com/news/166096.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Vue前端框架搭建过程
    目录一、安装 NodeJS二、安装 vue-cli三、创建项目一、安装 NodeJS 见 Windows下安装NodeJS。 二、安装 vue-cli 1.vue-cli 2.x 升...
    99+
    2022-11-13
  • JavaScript架构前端监控搭建过程步骤
    目录前言采集阶段:要采集哪些数据?前端异常接口异常行为数据API 阶段:搭建上报数据的 API 接口数据存储阶段:接口对接数据库查询统计阶段:数据查询和统计分析可视化阶段:最终的数据...
    99+
    2022-11-13
  • SpringBoot+MyBatisPlus+Vue 前后端分离项目快速搭建过程(前端篇)
    目录后端篇前端篇 创建vue项目安装所需工具开始编码启动前端测试后端篇 SpringBoot+MyBatisPlus+Vue 前后端分离项目快速搭建【后端篇】【快速生成后端...
    99+
    2022-11-12
  • 如何使用seajs库和Bootstrap框架搭建通用前端框架
    这篇文章主要介绍如何使用seajs库和Bootstrap框架搭建通用前端框架,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!前端框架主要研究了四点1、 研究Web框架的动态加载技术针对...
    99+
    2022-10-19
  • SpringBoot+MyBatisPlus+Vue 前后端分离项目快速搭建过程(后端)
    目录数据库准备后端搭建1、快速创建个SpringBoot项目2、引入依赖3、编写代码快速生成代码4、运行代码生成器生成代码5、编写application.properties6、在启...
    99+
    2022-11-12
  • python miniWeb框架搭建过程详解
    框架概念 框架和web服务器关系 ·静态资源:不是经常变化的资源、往往是固定不变的资源 ·动态资源:经常变化的资源 ·模板文件:提供了一个显示的模板,显示的内容不同,但是结构是一样...
    99+
    2022-11-12
  • golang beego框架环境搭建过程
    目录环境搭建1.开启gomod设置代理2.安装beego和bee3.升级bee4.zsh: command not found: bee5.bee相关命令6.项目启动7.beego项...
    99+
    2022-11-13
  • vue是不是前端css框架
    这篇文章主要讲解了“vue是不是前端css框架”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“vue是不是前端css框架”吧! v...
    99+
    2022-10-19
  • vue框架是前端还是后端的
    vue框架是属于前端的,现在vue一般都是指vue.js,vue-router,vuex的统称,它是一套构建web用户界面的渐进式框架,能够让基于网页的前端应用程序开发起来更加方便,可以对数据进行双向绑定,并且使用vue编写出来的界面效果都...
    99+
    2022-10-06
  • 前端框架vue该怎么入门
    本篇文章给大家分享的是有关前端框架vue该怎么入门,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。vue是现在很火的一个前端MVVM框架,它以数...
    99+
    2022-10-19
  • 移动前端框架配vue好吗
    近年来,随着移动互联网的快速发展,许多前端框架应运而生。现在,以vue为代表的前端框架已经成为了众多Web开发者的首选。那么,移动前端框架和vue相结合会产生怎样的效果呢?在选择合适的移动前端框架时,我们需要考虑哪些因素?一、移动前端框架的...
    99+
    2023-05-14
  • SpringCloud Alibaba 基本开发框架搭建过程
    目录1、创建多Module工程1.1、创建父工程1.2、创建子module 选中父项目,右键,新建module2、使用Gti进行版本控制2.1、初始化本地仓库 打开项目路径,右键gi...
    99+
    2022-11-12
  • vue的webpack框架如何搭建
    本篇内容主要讲解“vue的webpack框架如何搭建”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“vue的webpack框架如何搭建”吧!1、想要使用vue,我首先该怎么做?想要学习vue,我第...
    99+
    2023-07-04
  • Vue框架和前后端开发详解
    目录1. 抽象工厂模式2. UML图3. 代码示例4. 总结4.1 抽象工厂模式的总结4.2 工厂模式的总结1. 抽象工厂模式 针对工厂方法模式无法创建一组相关或相互依赖对象的问题,...
    99+
    2022-11-12
  • vue前端框架Mint UI怎么使用
    Mint UI 是一个基于 Vue.js 的移动端组件库,使用 Mint UI 可以快速构建移动端应用的界面。以下是在 Vue 项目...
    99+
    2023-08-09
    vue
  • docker 搭建部署 YAPI 框架的详细过程
    目录Yapi介绍优点:Yapi的几个功能1、启动 MongoDB2、获取 Yapi 镜像,版本信息可在 阿里云镜像仓库 查看3、初始化 Yapi 数据库索引及管理员账号4、启动 Ya...
    99+
    2022-11-13
    docker 搭建YAPI 框架 docker 搭建YAPI
  • python mysql项目实战及框架搭建过程
    前言 python+mysql.connector,demo实战 框架搭建 说实话,其实没有使用到框架,只是用了, python+mysql.connector模块 首先在开始虚拟环境: (vega-j-vI5S...
    99+
    2022-06-02
    python mysql项目实战 mysql项目实战 python 项目实战
  • Python之Web框架Django项目搭建全过程
    Python之Web框架Django项目搭建全过程 IDE说明: Win7系统 Python:3.5 Django:1.10 Pymysql:0.7.10 Mysql:5.5 注:...
    99+
    2022-06-04
    全过程 框架 项目
  • mockjs,json-server如何搭建前端通用的数据模拟框架
    这篇文章主要介绍mockjs,json-server如何搭建前端通用的数据模拟框架,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!一、使用的组件包1. mockjs:用于模拟查询结果2...
    99+
    2022-10-19
  • 怎么搭建SpringBoot+Vue前后端分离
    本文小编为大家详细介绍“怎么搭建SpringBoot+Vue前后端分离”,内容详细,步骤清晰,细节处理妥当,希望这篇“怎么搭建SpringBoot+Vue前后端分离”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。1...
    99+
    2023-07-05
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作