zoukankan      html  css  js  c++  java
  • vue3.0+vite+ts项目搭建(报错处理)

    报错一

    warning package.json: No license field
    $ vue-tsc --noEmit && vite build

     解决方案,添加这两行,只添加一个是没有用的

     报错二

    node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1193:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

     把tsconfig.json中的isolatedModules设置为false

    报错三

    yarn dev 不报错,build就报错

    $ vue-tsc --noEmit && vite build
    src/pages/home.vue:9:8 - error TS2339: Property 'appContext' does not exist on type 'ComponentInternalInstance | null'.

    src/utils/request.ts:7:16 - error TS7016: Could not find a declaration file for module 'qs'

     解决方式将package.json中的build部分改掉

     改成这个样子就不再报错也可以正常打包了

     报错四

    打包报错

    这个是打包配置文件写错了,改成这样就好了

     报错五

    打包的时候出现以下报错:

    warnings when minifying css:
    > <stdin>:9:1: warning: "@charset" must be the first rule in the file
    9 │ }@charset "UTF-8";

     解决方案:修改vite.config.ts文件配置

    css部分加上charset: false

    完整代码如图

     报错六

    vant采用cdn引入的方式报错

    Uncaught (in promise) TypeError: Cannot read property 'proxy' of null
    at Xe (vant.min.js:1)

     解决方案,换用从vite.config.ts中引入CDN

    上面这种报错是在从index.html引入CDN的情况下报错的

  • 相关阅读:
    Leetcode Binary Tree Preorder Traversal
    Leetcode Minimum Depth of Binary Tree
    Leetcode 148. Sort List
    Leetcode 61. Rotate List
    Leetcode 86. Partition List
    Leetcode 21. Merge Two Sorted Lists
    Leetcode 143. Reorder List
    J2EE项目应用开发过程中的易错点
    JNDI初认识
    奔腾的代码
  • 原文地址:https://www.cnblogs.com/ToBeBest/p/15597961.html
Copyright © 2011-2022 走看看