vue cli 环境搭建

1:设置华为云 npm 源路径: npm config set registry https://mirrors.huaweicloud.com/repository/npm/

2:查看源: npm config get registry

3: npm install -g @vue/cli 安装vue cli 客户端

4:查看vue cli 版本 vue --version vue -V

5:vue ui 查看 项目创建页面

vue3+ ts 使用vuecli 创建项目启动报错 ERROR in src/router/index.ts:1:64

TS7016: Could not find a declaration file for module 'vue-router'. './node_modules/vue-router/index.js' implicitly has an 'any' type.

Try npm i --save-dev @types/vue-router if it exists or add a new declaration (.d.ts) file containing declare module 'vue-router';

> 1 | import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";

| ^^^^^^^^^^^^

2 | import HomeView from "../views/HomeView.vue";

解决办法

1:在src 下 新建 shims-vue.d.ts

2:在router 下的 index.ts 中添加 type RouteRecordRaw = typeof RouteRecordRaw; 这个一句代码到 const routes: Array<RouteRecordRaw> 之前

=================================

6:安装 axios前后端交互工具 npm install -g axios

7: vue2 安装使用elementui

npm install -g element-ui

修改main.js

import Vue from "vue";

import App from "./App.vue";

import router from "./router";

import store from "./store";

//引入样式

import ElementUI from "element-ui";

import "element-ui/lib/theme-chalk/index.css";

Vue.config.productionTip = false;

//使用ElementUI

Vue.use(ElementUI);

new Vue({

router,

store,

render: (h) => h(App),

}).$mount("#app");

8:vue3 安装 element-plus

npm install -g element-plus

修复 "Cannot find module 'element-plus' or its corresponding type declarations" 错误

如果使用 TypeScript,需要添加类型声明:

对于 Vue 3 + Element Plus:

// 在 tsconfig.json 中

{

"compilerOptions": {

"types": "element-plus/global"

}

}

或在 shims-vue.d.ts 中添加:

// shims-vue.d.ts

declare module 'element-plus' {

import { Plugin } from 'vue'

const ElementPlus: Plugin

export default ElementPlus

}

对于 Vue 2 + Element UI:

npm install @types/element-ui

相关推荐
小小尚@6 小时前
WebGIS/ECharts 地图开发|MapLand 在线行政区划边界一键下载 GeoJSON 工具
前端·javascript·echarts
葡萄城技术团队6 小时前
工业数据可视化:使用活字格 AIcoding + Three.js 构建轻量化三维设备监控大屏
开发语言·javascript·信息可视化
默_笙7 小时前
🚍 一条 Todo 的奇幻漂流:TypeScript 全栈类型安全的"护照检查"
前端·javascript
计算机魔术师8 小时前
NVIDIA 以 129.3 亿美元收购 Hugging Face
前端
平头哥技术团队8 小时前
Day 01 | 用 HTML 写第一个网页:双击就能在浏览器打开
前端
weixin_422555428 小时前
el-menu子菜单点击就被激活,恢复之前的激活状态
javascript·vue.js·elementui
计算机魔术师8 小时前
两年翻45倍!英伟达靠买买买建成千亿投资帝国
前端
paopaokaka_luck9 小时前
基于springboot3+vue3的精准扶贫管理系统(AI 问答、ECharts 图形化分析)
前端·人工智能·echarts
l1m0_9 小时前
智能电动自行车管理后台实战:AI生成页面与React组件化技巧
前端·react.js·ui·ai·设计
Patrick_Wilson9 小时前
为什么gitlab的MR会默认有一个merge commit
前端·git·gitlab