百度小程序開(kāi)發(fā)第一坑tcomponent自定義組件命名坑Compile san component failed. . [SAN ERROR] ROOT>swan-custom-component>view>千萬(wàn)不要用下劃線(xiàn)作為自定義組件名
在給組件命名的時(shí)候我們大多數的時(shí)候命名字母全小寫(xiě)且包含一個(gè)連字符,但是有的時(shí)候我們也是用單詞首字母大寫(xiě)的方式實(shí)現的組件命名
如果當我們需要將組件渲染到dom上的時(shí)候強烈建議使用全部字母小寫(xiě)且有連接符連接的命名
在html中是大小寫(xiě)不敏感的,使用全小寫(xiě)且連接符連接會(huì )幫助我們與當前或者未來(lái)的元素沖突
百度自定義組件名不能用下劃線(xiàn)
正確示例
"navigationBarTitleText": "智能小程序示例",
"usingComponents": {
"qwbmlist": "/components/searchInput/qwbmlist",
"qwbm-list": "/components/searchList/qwbmlist",
"qwbm_list": "/components/searchList/qwbmlist", //這行就是有問(wèn)題的,因為用一下劃線(xiàn)
}
注意:組件的文件名可以用駝峰命名,但不能用中劃線(xiàn)
注意:組件名只能是全小寫(xiě)加中劃線(xiàn),不能用駝峰命名和下劃線(xiàn)
index 頁(yè)面引入
<qwbmlist></qwbmlist>
<qwbm-list></qwbm-list>
<qwbm_list></qwbm_list> //這行就是有問(wèn)題的,因為用一下劃線(xiàn)
Compile san component failed.
[SAN ERROR] ROOT>swan-custom-component>view>qwbm's close tag has attributes
Error: Compile san component failed.
[SAN ERROR] ROOT>swan-custom-component>view>qwbm's close tag has attributes
at X (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:49332)
at Object.Ye [as parseComponentTemplate] (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:72922)
at V (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:382573)
at B (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:382868)
at U (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:382979)
at p (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:830845)
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:831663
at a.getComponentType (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:831922)
at ke (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:60743)
at a.<anonymous> (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:80346)
at a.attach (D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\node_modules\@ecomfe\san-devhook\dist\san_devhook.js:2019:27)
at e.value (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:718106)
at e.value (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:715675)
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:712413
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:341978
at Array.forEach (<anonymous>)
ext msg: {}
(anonymous) @ D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator\src\webview\preloads\master\events.js:1
(anonymous) @ D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\src\services\event\renderer\event-map.js:1
emit @ events.js:203
onMessage @ electron/js2c/renderer_init.js:2422
D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator\src\webview\preloads\master\events.js:1
error from page:
D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator\src\webview\preloads\master\events.js:1 Slave attached error in _transitPageAttach function.
Cannot read property 'tagName' of undefined
TypeError: Slave attached error in _transitPageAttach function.
Cannot read property 'tagName' of undefined
at U (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:383202)
at p (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:830845)
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:831663
at a.getComponentType (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:831922)
at ke (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:60743)
at a.<anonymous> (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:80346)
at a.attach (D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\node_modules\@ecomfe\san-devhook\dist\san_devhook.js:2019:27)
at e.value (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:718106)
at e.value (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:715675)
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:712413
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:341978
at Array.forEach (<anonymous>)
at HTMLDocument.<anonymous> (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:341958)
at D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator-swan-api\src\webview\utils\message.js:1:279
at D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator-swan-api\src\webview\slave\index.js:1:1111
at EventEmitter.<anonymous> (D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\src\services\event\renderer\event-map.js:1:1116)
ext msg: {"isWhiteScreen":true}
如果當我們需要將組件渲染到dom上的時(shí)候強烈建議使用全部字母小寫(xiě)且有連接符連接的命名
在html中是大小寫(xiě)不敏感的,使用全小寫(xiě)且連接符連接會(huì )幫助我們與當前或者未來(lái)的元素沖突
百度自定義組件名不能用下劃線(xiàn)
正確示例
"navigationBarTitleText": "智能小程序示例",
"usingComponents": {
"qwbmlist": "/components/searchInput/qwbmlist",
"qwbm-list": "/components/searchList/qwbmlist",
"qwbm_list": "/components/searchList/qwbmlist", //這行就是有問(wèn)題的,因為用一下劃線(xiàn)
}
注意:組件的文件名可以用駝峰命名,但不能用中劃線(xiàn)
注意:組件名只能是全小寫(xiě)加中劃線(xiàn),不能用駝峰命名和下劃線(xiàn)
index 頁(yè)面引入
<qwbmlist></qwbmlist>
<qwbm-list></qwbm-list>
<qwbm_list></qwbm_list> //這行就是有問(wèn)題的,因為用一下劃線(xiàn)
Compile san component failed.
[SAN ERROR] ROOT>swan-custom-component>view>qwbm's close tag has attributes
Error: Compile san component failed.
[SAN ERROR] ROOT>swan-custom-component>view>qwbm's close tag has attributes
at X (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:49332)
at Object.Ye [as parseComponentTemplate] (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:72922)
at V (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:382573)
at B (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:382868)
at U (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:382979)
at p (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:830845)
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:831663
at a.getComponentType (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:831922)
at ke (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:60743)
at a.<anonymous> (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:80346)
at a.attach (D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\node_modules\@ecomfe\san-devhook\dist\san_devhook.js:2019:27)
at e.value (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:718106)
at e.value (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:715675)
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:712413
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:341978
at Array.forEach (<anonymous>)
ext msg: {}
(anonymous) @ D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator\src\webview\preloads\master\events.js:1
(anonymous) @ D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\src\services\event\renderer\event-map.js:1
emit @ events.js:203
onMessage @ electron/js2c/renderer_init.js:2422
D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator\src\webview\preloads\master\events.js:1
error from page:
D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator\src\webview\preloads\master\events.js:1 Slave attached error in _transitPageAttach function.
Cannot read property 'tagName' of undefined
TypeError: Slave attached error in _transitPageAttach function.
Cannot read property 'tagName' of undefined
at U (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:383202)
at p (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:830845)
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:831663
at a.getComponentType (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:831922)
at ke (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:60743)
at a.<anonymous> (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:80346)
at a.attach (D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\node_modules\@ecomfe\san-devhook\dist\san_devhook.js:2019:27)
at e.value (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:718106)
at e.value (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:715675)
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:712413
at file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:341978
at Array.forEach (<anonymous>)
at HTMLDocument.<anonymous> (file:///C:/Users/Administrator/AppData/Roaming/%E7%99%BE%E5%BA%A6%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7/cli/vendor/swan-core/3.300.10/slaves/index.js:1:341958)
at D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator-swan-api\src\webview\utils\message.js:1:279
at D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\extensions\simulator-swan-api\src\webview\slave\index.js:1:1111
at EventEmitter.<anonymous> (D:\Program Files\swan-ide-gui\resources\app\build-3.33.1\app.asar\dist\src\services\event\renderer\event-map.js:1:1116)
ext msg: {"isWhiteScreen":true}
前一頁(yè):暫時(shí)沒(méi)有數據
后一頁(yè):開(kāi)始百度小程序開(kāi)發(fā)需要準備工作
- 網(wǎng)站公告
- Notice
- 教程指南
- Course
- 點(diǎn)擊在線(xiàn)咨詢(xún)
- 手機 13961347334
- Q Q 565449214
- 郵箱 565449214@qq.com