提交 2f420ce3 编写于 作者: fxy060608's avatar fxy060608

fix(mp-weixin): unicloud-db

上级 8efde992
...@@ -426,20 +426,25 @@ function isPlainObject (obj) { ...@@ -426,20 +426,25 @@ function isPlainObject (obj) {
return _toString.call(obj) === '[object Object]' return _toString.call(obj) === '[object Object]'
} }
function initBuiltInEasycom (components, usingAutoImportComponents) {
components.forEach(name => {
const easycomName = `^${name}$`
if (!usingAutoImportComponents[easycomName]) {
usingAutoImportComponents[easycomName] =
'@dcloudio/uni-cli-shared/components/' + name + '.vue'
}
})
}
function initAutoImportComponents (easycom = {}) { function initAutoImportComponents (easycom = {}) {
let usingAutoImportComponents = easycom.custom || easycom || {} let usingAutoImportComponents = easycom.custom || easycom || {}
if (!isPlainObject(usingAutoImportComponents)) { if (!isPlainObject(usingAutoImportComponents)) {
usingAutoImportComponents = {} usingAutoImportComponents = {}
} }
initBuiltInEasycom(BUILT_IN_EASYCOMS, usingAutoImportComponents)
// 目前仅 mp-weixin 内置支持 page-meta 等组件 // 目前仅 mp-weixin 内置支持 page-meta 等组件
if (process.env.UNI_PLATFORM !== 'mp-weixin') { if (process.env.UNI_PLATFORM !== 'mp-weixin') {
BUILT_IN_COMPONENTS.forEach(name => { initBuiltInEasycom(BUILT_IN_COMPONENTS, usingAutoImportComponents)
const easycomName = `^${name}$`
if (!usingAutoImportComponents[easycomName]) {
usingAutoImportComponents[easycomName] =
'@dcloudio/uni-cli-shared/components/' + name + '.vue'
}
})
} }
const newUsingAutoImportComponentsJson = JSON.stringify(usingAutoImportComponents) const newUsingAutoImportComponentsJson = JSON.stringify(usingAutoImportComponents)
...@@ -504,13 +509,18 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) { ...@@ -504,13 +509,18 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
return autoImportComponents return autoImportComponents
} }
const BUILT_IN_COMPONENTS = ['page-meta', 'navigation-bar', 'uni-match-media', 'unicloud-db'] const BUILT_IN_COMPONENTS = ['page-meta', 'navigation-bar', 'uni-match-media']
function isBuiltInComponent (name) { const BUILT_IN_EASYCOMS = ['unicloud-db']
function isBuiltInComponent (name) { // uni-template-compiler/lib/util.js 识别微信内置组件
return BUILT_IN_COMPONENTS.includes(name) return BUILT_IN_COMPONENTS.includes(name)
} }
function isBuiltInComponentPath (modulePath) { function isBuiltInComponentPath (modulePath) { // 内置的 easycom 类组件
if (BUILT_IN_EASYCOMS.find(name => modulePath.includes(name))) {
return true
}
return !!BUILT_IN_COMPONENTS.find(name => modulePath.includes(name)) return !!BUILT_IN_COMPONENTS.find(name => modulePath.includes(name))
} }
......
...@@ -78,8 +78,9 @@ function processElement (ast, state, isRoot) { ...@@ -78,8 +78,9 @@ function processElement (ast, state, isRoot) {
if (ast.attr.id && ast.attr.id.indexOf('{{') === 0) { if (ast.attr.id && ast.attr.id.indexOf('{{') === 0) {
state.tips.add(`id 作为属性保留名,不允许在自定义组件 ${ast.type} 中定义为 props`) state.tips.add(`id 作为属性保留名,不允许在自定义组件 ${ast.type} 中定义为 props`)
} }
if (hasOwn(ast.attr, 'data') && platformName !== 'mp-toutiao') { // 百度中会出现异常情况 if (hasOwn(ast.attr, 'data') && platformName !== 'mp-toutiao') { // 百度中会出现异常情况
state.tips.add(`data 作为属性保留名,不允许在自定义组件 ${ast.type} 中定义为 props`) // TODO 暂不输出
// state.tips.add(`data 作为属性保留名,不允许在自定义组件 ${ast.type} 中定义为 props`)
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册