关于#typescript#的问题:创建v3 + ts + vite项目报错使用创建.ts文件添加代码

创建v3 + ts + vite项目报错

img


使用创建.ts文件添加代码

declare module '*.vue' {
    import { ComponentOptions } from 'vue'

    const componentOptions: ComponentOptions

    export default componentOptions

}

依旧报红

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 你可以参考下这个问题的回答, 看看是否对你有帮助, 链接: https://ask.csdn.net/questions/7760149
  • 这篇博客你也可以参考下:【Vue3+Ts+Vite】使用Vite与TS构建Vue3项目
  • 除此之外, 这篇博客: TypeScript 笔记中的 vue3 + vite + ts 移动端适配 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:

    使用插件:
    amfe-flexible
    postcss-pxtorem

    1、
    安装 amfe-flexible
    主要是将1rem设为viewWidth/10。
    npm install amfe-flexible --save

    //main.ts
    import 'amfe-flexible';
    

    2、
    npm install postcss-pxtorem --save
    在src同级目录下创建 postcss.config.js
    rootValue 的值为设计稿10分之一的大小,比如750px的设计稿 rootValue则为75

    module.exports = {
      "plugins": {
          'postcss-pxtorem': {
              rootValue: 75,
              propList: ['*']
          }
      }
    }
    

    3、
    index.html中

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    
  • 以下回答来自chatgpt:

    很抱歉,参考资料中并没有提到添加.ts文件的问题以及相关的报错和红色提示。所以我需要更多的信息来帮助你解决这个问题。具体来说,我需要看到你的代码和错误信息,才能给出相关的解决方案。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^