当前位置:   article > 正文

vue3使用element实现表单列表,报错[vite] Internal server error: No known conditions for “./lib/theme-chalk/index_no known conditions for "./lib/theme-chalk/index.c

no known conditions for "./lib/theme-chalk/index.css" specifier in "element-

vue3使用element实现表单列表,报错[vite] Internal server error: No known conditions for “./lib/theme-chalk/index.css” specifier in “element-plus” package

问题背景

vue3项目中引入element plus 时 引入 element css报错:

[vite] Internal server error: No known conditions for "./lib/theme-chalk/index.css" specifier in "element-plus" package
  • 1

问题分析

import 'element-plus/lib/theme-chalk/index.css' // 多了个lib
import ElementPlus from 'element-plus'
  • 1
  • 2

检查得知,包路径多了个lib,删除后可以正常使用,如下所示:

import 'element-plus/theme-chalk/index.css'
import ElementPlus from 'element-plus'
  • 1
  • 2

问题解决

正常引入element以及其样式文件后,实现表单列表,代码如下:

<template>
  <div>
    <div class="search-line">
      <label>姓名</label>
      <input style="margin-left: 10px;" placeholder="请输入姓名">
      <label style="margin-left: 30px;">证件号码</label>
      <input style="margin-left: 10px;" placeholder="请输入证件号码">
      <el-button type="primary" style="margin-left: 20px;">搜索</el-button>
    </div>
    <div class="list">
      <el-table stripe :data="tableData" style="width: 100%">
        <el-table-column prop="no" label="序号" width="80">
        </el-table-column>
        <el-table-column prop="idNumber" label="证件号码" width="230">
        </el-table-column>
        <el-table-column prop="phone" label="联系方式" width="200">
        </el-table-column>
        <!-- <el-table-column prop="address" label="地址">
        </el-table-column> -->
        <el-table-column label="地址">
          <el-table-column prop="province" label="省份" width="120">
          </el-table-column>
          <el-table-column prop="city" label="市区" width="120">
          </el-table-column>
          <el-table-column prop="address" label="地址" width="100">
          </el-table-column>
        </el-table-column>
        <el-table-column prop="upTime" label="上报时间" width="180">
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template slot-scope="scope" style="display: flex;">
            <el-button size="mini">编辑</el-button>
            <el-button size="mini" type="danger">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

  </div>
</template>
 
<script>
import { mapMutations } from 'vuex'

export default {
  name: 'Login',
  data() {
    return {
      username: '',
      password: '',
      tableData: [{
        "no": "1",
        "idNumber": "893580235129058230580",
        "phone": "12323278478",
        "province": '江西',
        'city': '上饶',
        "address": '武汉市',
        "upTime": '2023-10-13 14:47',
      }, {
        "no": "1",
        "idNumber": "893580235129058230580",
        "phone": "12323278478",
        "province": '浙江',
        'city': '杭州',
        "address": '武汉市',
        "upTime": '2023-10-13 14:47',
      }, {
        "no": "1",
        "idNumber": "893580235129058230580",
        "phone": "12323278478",
        "province": '湖北',
        'city': '武汉',
        "address": '武汉市',
        "upTime": '2023-10-13 14:47',
      }],
    }
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    }
  },
}
</script>

<style>
.search-line {
  display: flex;
  align-items: center;
}

.list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
}
</style>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100

运行结果如下:
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/119163
推荐阅读
相关标签
  

闽ICP备14008679号