Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用<template></template>标签报错,类型“IntrinsicElements”上不存在属性“template” #189

Open
imleeou opened this issue Nov 30, 2024 · 6 comments

Comments

@imleeou
Copy link

imleeou commented Nov 30, 2024

Bug report(问题描述)

我在使用unibest模版时,使用<template></template>标签时会标红,报错内容:【类型“IntrinsicElements”上不存在属性“template”。ts-plugin(2339)】

我的其他自己搭建的uniapp vue3 项目没有这个问题

Steps to reproduce(问题复现步骤)

  1. 使用pnpm create unibest my-project 创建项目
  2. create-unibest@v1.13.0
  3. 快速创建,选择base[推荐]
  4. pnpm i 安装依赖,写一个标签 <template>123</template>

Screenshot or Gif(截图或动态图)

image

minimal reproduction(最小可还原代码)

按步骤创建就可复现

System Info

npx envinfo --system --npmPackages vue --binaries --browsers

执行上面命令,将结果贴下面

  System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 51.73 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    Yarn: 1.22.19 - ~/Library/pnpm/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
    pnpm: 9.14.4 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 131.0.6778.86
    Safari: 18.0
@w3313003
Copy link

image
same question

@w3313003
Copy link

暂时添加配置后不飘红了

import Vue, { VNode } from 'vue'

declare global {
  namespace JSX {
    interface Element extends VNode {}
    interface ElementClass extends Vue {}
    interface IntrinsicElements {
      [elem: string]: any
    }
  }
}

@skyeryg
Copy link

skyeryg commented Dec 5, 2024

重启一下vue扩展就可以,扩展的问题

@luniard
Copy link

luniard commented Dec 5, 2024

暂时添加配置后不飘红了

import Vue, { VNode } from 'vue'

declare global {
  namespace JSX {
    interface Element extends VNode {}
    interface ElementClass extends Vue {}
    interface IntrinsicElements {
      [elem: string]: any
    }
  }
}

在哪里配置

@wuhao1477
Copy link

解决了嘛同样的问题

@wuhao1477
Copy link

解决了

修改tsconfig.json文件

{
  "compilerOptions": {
    "composite": true,
    "skipLibCheck": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "noImplicitThis": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": true,
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"],
      "#/*": ["./src/types/*"]
    },
    "outDir": "dist",
    "lib": ["esnext", "dom"],
    "types": [
      "@dcloudio/types",
      "@uni-helper/uni-types",
      "@types/wechat-miniprogram",
      "wot-design-uni/global.d.ts",
+      "vue/jsx" // 添加这一行
    ]
  },
  // ... orther config
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants