Vuejs 使用介绍

发布时间: 更新时间: 总字数:281 阅读时间:1m 作者:IP:上海 网址

Vuejs 使用介绍技术专题与文档汇总,系统梳理 vue、vuejs 核心概念、架构原理、实战配置与开发指南。

安装

bash
npm i -g @vue/cli

创建项目

text
vue create <name>
cd <name>
npm run serve

运行

基于 Vue CLI 的项目:

bash
npm install
npm run serve
# 生产打包
npm run build

如果是基于 Vite 的现代 Vue 项目:

bash
npm install
npm run dev
# 生产打包
npm run build

插件

开发插件 vue-devtools

https://github.com/vuejs/vue-devtools

clean-webpack-plugin

Installation, in webpack project home dir:

bash
npm install --save-dev clean-webpack-plugin

Usage, add to webpack.config.js:

javascript
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

const webpackConfig = {
    plugins: [
        /**
         * All files inside webpack's output.path directory will be removed once, but the
         * directory itself will not be. If using webpack 4+'s default configuration,
         * everything under <PROJECT_DIR>/dist/ will be removed.
         * Use cleanOnceBeforeBuildPatterns to override this behavior.
         *
         * During rebuilds, all webpack assets that are not used anymore
         * will be removed automatically.
         *
         * See `Options and Defaults` for for information
         */
        new CleanWebpackPlugin(),
    ],
};

module.exports = webpackConfig;

ref: https://github.com/johnagan/clean-webpack-plugin

问题

跨域问题

chrome 安装 Moesif Orign & CORS Changer 插件,并开启

?raw 什么作用

  • 将改变任何类型文件的字符串导入(参考)
javascript
import richtextRedo from '../assets/richtext_redo.svg?raw';