前端项目导入vue和element

news2024/10/5 14:15:25

1.安装nodejs

下载链接icon-default.png?t=N7T8https://cdn.npmmirror.com/binaries/node/v18.18.0/node-v18.18.0-x64.msi

进入cmd 命令行模式 管理员身份运行

输入 (node -v)能看到版本号

npm config set prefix "C:\Program Files\nodejs"  默认路径

npm config set prefix " 写你安装的路径 "

切换npm 的淘宝镜像(npm config set registry https://registry.npm.taobao .org)

2.安装vue/cli

输入( npm install -g @vue/cli )

 出现错误 根据错误  搜索

安装好了 输入(nue  ui)

浏览器自动打开  (http://localhost:8000) 这个网页 我们在这里创建项目

桌面创建一个文件夹复制路径       get 关掉

路径改好了 输入项目名称 点击创建

 

点击创建就行了

然后刚刚启动vue 的cmd 窗口 能看到 创建项目

 等几分钟完成

 

启动项目 

导入vscode 搜索框输入npm

选择第一个 然后就启动了

看到这个已经启动了    

    打开浏览器输入  http://localhost:8080/然后看到vue的见面

先停掉项目

进入vscode终端按ctrl+c

 安装element

vscode 里面项目文件夹(右键) 点击(在集成终端中打开)

输入 npm install element-ui@2.15.3

 出现错误 根据错误  搜索

项目文件里  看到这个文件 "node_modules\element-ui"已经安装好了

引入elemnt

vue.config.js

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
   devServer:{
  port:7000
   }
})

main.js 文件

import Vue from 'vue'
import App from './App.vue'
import router from './router'
// eliment引入的
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.config.productionTip = false
// eliment引入的
Vue.use(ElementUI);

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

app.vue

<template>
  <div>
    <!-- <h1>{{ message }}</h1>  -->

    <!-- <emp-view></emp-view> -->
    <element-view></element-view>

  </div>
</template>


<script>
import  ElementView from './views\element\ElementView.vue'


export default {

  components: { ElementView},
  data() {
    return {
      message: "hello vue111",
    }
  },
  methods: {

  }
}
</script>
<style></style>

 ElementView.vue

<template>
  <div>
    <el-row>
      <el-button round>圆角按钮</el-button>
      <el-button type="primary" round>主要按钮</el-button>
      <el-button type="success" round>成功按钮</el-button>
      <el-button type="info" round>信息按钮</el-button>
      <el-button type="warning" round>警告按钮</el-button>
      <el-button type="danger" round>危险按钮</el-button>
    </el-row>

    <!--     <el-row>
  <el-button icon="el-icon-search" circle></el-button>
  <el-button type="primary" icon="el-icon-edit" circle></el-button>
  <el-button type="success" icon="el-icon-check" circle></el-button>
  <el-button type="info" icon="el-icon-message" circle></el-button>
  <el-button type="warning" icon="el-icon-star-off" circle></el-button>
  <el-button type="danger" icon="el-icon-delete" circle></el-button>
</el-row> -->

    <!-- 表格 -->
    <br>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="date" label="日期" width="180">
      </el-table-column>
      <el-table-column prop="name" label="姓名" width="180">
      </el-table-column>
      <el-table-column prop="address" label="地址">
      </el-table-column>
    </el-table>
    <!-- pagination -->
    <!-- <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination> -->
    <el-pagination background layout="total,sizes, prev, pager, next, jumper, ->,  slot" @size-change="handleSizeChange"
      @current-change="handleCurrentChange" :total="1000"></el-pagination>
    <div>
      <el-button type="text" @click="dialogTableVisible = true">打开嵌套表格的 Dialog</el-button>
      <br>
      <!-- 对话框 -->
      <el-dialog title="收货地址" :visible.sync="dialogTableVisible">
        <el-table :data="gridData">
          <el-table-column property="date" label="日期" width="150"></el-table-column>
          <el-table-column property="name" label="姓名" width="200"></el-table-column>
          <el-table-column property="address" label="地址"></el-table-column>
        </el-table>
      </el-dialog>


      <!-- 对话框for -->
      <el-button type="text" @click="dialogFormeVisible = true">打开嵌form的 Dialog</el-button>
      <!-- <el-table title="form表单" :visible.sync="dialogFormeVisible"></el-table> -->
      <el-dialog title="收货地址" :visible.sync="dialogFormeVisible">
        <el-input v-model="input" placeholder="请输入内容"></el-input>

      </el-dialog>


      <br>

      <!-- 对话框for -->
      <el-button type="text" @click="Visible = true">打开嵌套表格的 Dialog</el-button>
      <el-dialog title="收货地址" :visible.sync="Visible">
        <el-input v-model="input" placeholder="请输入内容"></el-input>
        <el-table :data="gridData">
          <el-table-column property="date" label="日期" width="150"></el-table-column>
          <el-table-column property="name" label="姓名" width="200"></el-table-column>
          <el-table-column property="address" label="地址"></el-table-column>
        </el-table>

      </el-dialog>


    </div>
    <el-button type="text" @click="Visibleed = true">打开嵌套表格的 Dialog</el-button>
    <el-dialog title="收货地址" :visible.sync="Visibleed">
      
      <el-form ref="form" :model="form" label-width="80px">
  <el-form-item label="活动名称">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
  <el-form-item label="活动区域">
    <el-select v-model="form.region" placeholder="请选择活动区域">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="活动时间">
    <el-col :span="11">
      <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
    </el-col>
    <el-col class="line" :span="2">-</el-col>
    <el-col :span="11">
      <el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
    </el-col>
  </el-form-item>
  
  <el-form-item>
    <el-button type="primary" @click="onSubmit">立即创建</el-button>
    <el-button>取消</el-button>
  </el-form-item>
</el-form>

    </el-dialog>

  </div>
</template>

<script>

export default {
  data() {
    return {
      form:{
        name: '',
          region: '',
          date1: '',
          date2: '',
      },
      gridData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }],
      dialogTableVisible: false,
      dialogFormeVisible: false,
      Visible: false,
      Visibleed: false,



      tableData: [
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        },
      ],
    };

  },
  methods: {
    handleSizeChange: function (val) {
      alert("每页记录变化" + val)

    },
    handleCurrentChange: function (val) {
      alert("每页记录数变化" + val)

    },
    onSubmit:function(){
        alert(JSON.stringify(this.form));
    }
  }
};









</script>

<style ></style>

自己创建一个文件 src\views\名字文件夹的\ElementView.vue 注意大小

app.文件

错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: day5-demo@0.0.0
npm ERR! Found: vue@3.0.2
npm ERR! node_modules/vue
npm ERR!   peer vue@"3.0.2" from @vue/compiler-sfc@3.0.2
npm ERR!   node_modules/@vue/compiler-sfc
npm ERR!     peer @vue/compiler-sfc@"*" from rollup-plugin-vue@6.0.0-beta.10
npm ERR!     node_modules/rollup-plugin-vue
npm ERR!       rollup-plugin-vue@"^6.0.0-beta.10" from vite@1.0.0-rc.6
npm ERR!       node_modules/vite
npm ERR!         dev vite@"^1.0.0-rc.1" from the root project
npm ERR!     @vue/compiler-sfc@"^3.0.0-rc.10" from vite@1.0.0-rc.6
npm ERR!     node_modules/vite
npm ERR!       dev vite@"^1.0.0-rc.1" from the root project
npm ERR!     1 more (the root project)
npm ERR!   vue@"^3.0.0-rc.10" from vite@1.0.0-rc.6
npm ERR!   node_modules/vite
npm ERR!     dev vite@"^1.0.0-rc.1" from the root project
npm ERR!   1 more (the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! vue-router@"4.0.13" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: vue@3.2.41
npm ERR!   peer vue@"^3.2.0" from vue-router@4.0.13
npm ERR!   node_modules/vue-router
npm ERR!     vue-router@"4.0.13" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\zeyi\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:

根据错误提示,在命令行中加入–legacy-peer-deps,由于vue与vue-router版本兼容的问题,需要在安装语句后加入需要下载vue-router版本,不然会下载最新的vue-router版本。

npm install --legacy-peer-deps vue-router@4.0.13

也有可能因为是你要下载的router版本过高,如果下载版本过高,在启动项目时会报错,可以下载低版本的vue-router

npm install vue-router@3.1.3 --save-dev

最后在package.json文件中查看是否下载成功

npm install element-ui@2.15.3

错误

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Admin\AppData\Local\npm-cache\_logs\2022-06-14T08_44_12_502Z-debug-0.log
  1. 删除node_modules和package-lock.json,然后运行

    npm install
    
  2. 或尝试清除NPM缓存

    npm cache clean --force
    
  3. 或使用--legacy-peer-deps选项运行命令

    npm install --legacy-peer-deps
    
  4. 或使用--force选项运行命令

    npm install --force
  5. npm install element-ui@2.15.3

错误

  npm install --legacy-peer-deps

A complete log of this run can be found in: C:\Users\Mamkap\AppData\Local\npm-cache\_logs\2023-11-08T03_49_10_551Z-debug-0.log
Waiting for the debugger to disconnect...

  1. 执行 npm install npm@latest -g 升级到最新版本(若升级到最新版本还是报错,则还需要再全局更新一下npm,更新后检查npm版本号不会变,内部应该有更新);
  2. .删除本地node_modules 依赖包;
  3. 执行 npm cache clean --force 清理缓存;
  4. npm i 安装依赖;
    以上过程,尝试一次不行,可以多尝试几次就OK了

错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: vol.vue3@0.1.0
npm ERR! Found: vue@3.2.20
npm ERR! node_modules/vue
npm ERR!   vue@"^3.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.5.17" from element-ui@2.15.6
npm ERR! node_modules/element-ui
npm ERR!   element-ui@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Administrator\AppData\Local\npm-cache\eresolve-report.txt for a full report.
 
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2021-10-11T06_27_44_908Z-debug.log

npm i element-ui @xdh/my --legacy-peer-deps

npm install npm -g 更新一下

我这里是使用清除npm的缓存解决的 (npm cache clean --force)

错误

解决方案:

降级npm到6版本,在终端运行以下命令

npm install --legacy-peer-deps

npm install vue@2.5.17 --save

npx -p npm@6 npm i --legacy-peer-deps

这个错误通常是由于 npm 无法解决依赖关系而引起的。你可以尝试以下几个步骤
1.清除npm 缓存: npm cache clean --force
2.更新 npm: npm install -g npm@latest
3.删除 node modules 文件夹:rm -rf node modules
4.删除 package-lock.json 文件: rm -rf package-lock.json
5.重新安装依赖: npm install 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1184462.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

网页【CSS】滚动条

前言 优化后的滚动条会提亮我们的网站页面。 例如&#xff1a;CSS-TRICKS这个网站如果采用的是浏览器默认的滚动条&#xff0c;不进行优化&#xff0c;页面会显得很不搭。 所以该网站的滚动条样式优化如下&#xff1a; html::-webkit-scrollbar {width: 30px;height: 30px; …

基于Springboot的时装购物系统(有报告)。Javaee项目,springboot项目。

演示视频&#xff1a; 基于Springboot的时装购物系统&#xff08;有报告&#xff09;。Javaee项目&#xff0c;springboot项目。 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&#xff09;三层体系结构&…

notepad++搜索结果窗口不见了

1、使用notepad打开一个文件文件 2、ctrlf&#xff0c;打开搜索窗口&#xff0c;随便搜索一个内容 3、按F7,然后AltF7 切换焦点到Find result. 会有一个小窗口出现&#xff0c;内容是&#xff1a;还原&#xff0c;移动&#xff0c;大小等 4&#xff0c;点移动&#xff0c;使…

打造高效的客服体系,就在于这个“专属链接”

想要追踪特定数据&#xff0c;但是得在数据库中大海捞针&#xff1f; 想要知道某个推广的效果&#xff0c;但是无法追踪&#xff1f; 想要获得个性化的报告&#xff0c;但是数据不够精准&#xff1f; 面对这些情况&#xff0c;只需要靠一条“专属链接”就能一一击破&#xff…

WebGL的技术难点分析

WebGL是一项强大的技术&#xff0c;但在开发过程中可能会遇到一些挑战和技术难点。以下是一些与WebGL相关的技术难点&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c;欢迎交流合作。 1.3D数学和图形编程&#xff1a;理…

数据可视化PCA与t-SNE

PCA&#xff08;主成分分析&#xff09;和t-SNE&#xff08;t分布随机近邻嵌入&#xff09;都是降维技术&#xff0c;可以用于数据的可视化和特征提取。 降维&#xff1a;把数据或特征的维数降低&#xff0c;其基本作用包括&#xff1a; 提高样本密度&#xff0c;以及使基于欧…

将idea默认折叠的注释打开

idea默认的代码注释是折叠的&#xff0c;不方便查看 下面是改成默认打开的步骤 1、打开settings 2、找到Code Folding,将 Annotations前面的 对钩去掉&#xff0c;保存即可

【C++初阶(五)类和对象(上)】

本专栏内容为&#xff1a;C学习专栏&#xff0c;分为初阶和进阶两部分。 通过本专栏的深入学习&#xff0c;你可以了解并掌握C。 &#x1f493;博主csdn个人主页&#xff1a;小小unicorn ⏩专栏分类&#xff1a;C &#x1f69a;代码仓库&#xff1a;小小unicorn的代码仓库&…

Flink 基础 -- 尝试Flink

官网 文档 v1.18.0 下载 数据流上的状态计算(Stateful Computations over Data Streams) Apache Flink是一个框架和分布式处理引擎&#xff0c;用于无界和有界数据流的有状态计算。Flink被设计成可以在所有常见的集群环境中运行&#xff0c;以内存中的速度和任何规模执行计…

实验(一):运算器实验

一、实验内容与目的 实验要求&#xff1a; 利用 CP226 实验仪的 K16..K23开关做为DBUS数据&#xff0c;其它开关做为控制信号&#xff0c;将数据写累加器A和工作寄存器W&#xff0c;并用开关控制ALU的运算方式&#xff0c;实现运算器的功能&#xff0c;将结果送入OUT寄存器。 实…

软件工程第十周

测试过程 单元测试 注意出错处理&#xff01;单元测试的数据处理部分请见Junit 单元测试之错误和异常处理-CSDN博客 单元测试准则 白盒&#xff1a;对系统结构非常清楚&#xff01;就像大题注重过程。 单元测试的测试环境 一定要保证整个环境是完整的&#xff0c;尽管可能没…

读写锁ReentrantReadWriteLock

读写锁ReentrantReadWriteLock是JDK1.5提供的一个工具锁&#xff0c;适用于读多写少的场景&#xff0c;将读写分离&#xff0c;从而提高并发性。读写锁允许的情况&#xff1a;一个资源可以被多个读操作访问&#xff0c;或者被一个写操作访问&#xff0c;但两者不能同时进行。 R…

IP地址会暴露我们的隐私吗?

IP地址在某种程度上可能会暴露个人或组织的隐私。以下是一些关于IP地址可能影响隐私的情况&#xff1a; 地理位置信息&#xff1a; IP地址的一部分信息是与地理位置相关的&#xff0c;因此可以用于确定用户或组织的大致地理位置。这可能泄露用户的身份或活动的地理背景。 互联…

Doris:Binlog Load导入数据

Binlog Load提供了一种使Doris增量同步用户在Mysql数据库的对数据更新操作的CDC(Change Data Capture)功能。Binlog Load需要依赖canal作为中间媒介&#xff0c;让canal伪造成一个从节点去获取Mysql主节点上的Binlog并解析&#xff0c;再由Doris去获取Canal上解析好的数据。 1…

centos k8s安装dapr

文章目录 安装helm更新helm库初始化dapr高可用方式安装 卸载dapr验证k8s的dapr安装rocketmq总结 安装helm 三个包放到一个目录下 chmod x get ./get helm version更新helm库 helm repo add dapr https://dapr.github.io/helm-charts/ helm repo update helm search repo dapr …

C/C++轻量级并发TCP服务器框架Zinx-游戏服务器开发004:游戏核心消息处理 - 玩家类的实现

文章目录 0 代码仓库1 需求2 AOI设计2.1 AOI算法简介2.2 AOI数据结构及实现2.2.1 玩家2.2.2 网格对象2.2.3 游戏世界矩形2.2.4 获取周围玩家的实现2.2.5 代码测试 2.3 GameRole结合AOI创建玩家2.3.1 创建游戏世界全局对象-GameRole继承AOIWorld的Player2.3.2 把玩家到游戏世界的…

Qt OpenMP使用

1、概念 OpenMP是一种用于共享内存并行系统的多线程程序设计方案&#xff0c;支持的编程语言包括C、C和Fortran。OpenMP提供了对并行算法的高层抽象描述&#xff0c;特别适合在多核CPU机器上的并行程序设计。编译器根据程序中添加的pragma指令&#xff0c;自动将程序并行处理&…

匿名类型与元组(ValueTuple)

匿名类型与元组&#xff08;ValueTuple&#xff09; 匿名类型 简介&#xff1a;匿名类型提供了一种方便的方法&#xff0c;可用来将一组相关的属性封装到单个对象中。匿名对象由编译器在编译时动态生成&#xff0c;它是只读的&#xff0c;且只在当前作用域中可见。它可以方便…

CDN加速技术:降低企业云服务成本的有效利用

在当今数字化时代&#xff0c;云服务已经成为企业运营的不可或缺的一部分。然而&#xff0c;与此同时&#xff0c;云服务的需求也在不断增长&#xff0c;使企业不得不应对更大的数据传输和负载。这就引出了一个关键问题&#xff1a;如何有效降低企业云服务成本&#xff0c;同时…