mvlyforever
mvlyforever
  • 发布:2022-07-11 00:55
  • 更新:2023-07-11 23:04
  • 阅读:3885

Vue3.0 中 app.config.compilerOptions.isCustomElement 不起效

分类:uni-app

app.config.compilerOptions.isCustomElement = tag => tag.startsWith('wx-open-launch-weapp')

不起效。
提示错误↓↓↓↓

The compilerOptions config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, compilerOptions must be passed to @vue/compiler-dom in the build setup instead.

如何配置编译时,忽略 wx-open-launch-weapp 标签呢???

2022-07-11 00:55 负责人:无 分享
已邀请:
DCloud_UNI_WZF

DCloud_UNI_WZF

vue 文档中有写到该配置选项只在完整的构建版本中生效 (即可以在浏览器中编译模板的独立版 vue.js)。如果你使用的是附带额外构建设置的仅运行时版本,编译器选项必须通过构建工具的配置传入@vue/compiler-dom 以替代。
请确认是否是该问题导致提示错误,如果是的话可参考该配置:

import {    
    defineConfig    
} from 'vite'    
import uni from '@dcloudio/vite-plugin-uni'    

export default defineConfig({    
    plugins: [    
        uni({    
            vueOptions: {    
                template: {    
                    compilerOptions: {    
                        // 将所有my-开头的标签作为自定义元素处理    
                        isCustomElement: tag => tag.startsWith("")    
                    }    
                }    
            }    
        })    
    ]    
})
嫣旖雲之逸

嫣旖雲之逸

已按提供的配置设置了,但无效果。该怎么解决???
package.js:

"devDependencies": {  
    "@dcloudio/types": "^3.3.2",  
    "@dcloudio/uni-automator": "3.0.0-3080720230703001",  
    "@dcloudio/uni-cli-shared": "3.0.0-3080720230703001",  
    "@dcloudio/uni-stacktracey": "3.0.0-3080720230703001",  
  **  "@dcloudio/vite-plugin-uni": "3.0.0-3080720230703001",**  
    "babel-plugin-import": "^1.13.6",  
    "dotenv": "^16.3.1",  
    "fs": "^0.0.1-security",  
    "sass": "^1.63.6",  
    "sass-loader": "^13.3.2",  
    "vite": "4.1.4",  
    "vite-plugin-style-import": "^1.4.1"  
  },  

vite.config.js:

plugins: [  
            uni({      
                vueOptions: {      
                    template: {      
                        compilerOptions: {      
                            isCustomElement: tag => tag.startsWith("")      
                        }      
                    }      
                }      
            })  
],

要回复问题请先登录注册