ly525/luban-h5

新加了组件,预览报错

zy654781296 opened this issue · 3 comments

问题描述
简明扼要的描述你的问题
项目中新加了一个组件,在预览的时候报错,无法正常预览。

image

代码如下:

import PropTypes from '@luban-h5/plugin-common-props'

import { Grid, GridItem } from 'vant'

import 'vant/lib/grid/style'
import 'vant/lib/grid-item/style'

function getDefaultItems () {
const defaultItems = [
{
itemName: '邀请有礼',
imgUrl:
'http://appdev.yinqihui.net.cn:9500/group1/M00/01/18/oYYBAGEnZh2AFxqBAAADVGyCJnw685.png'
},
{
itemName: '自动充值',
imgUrl:
'http://appdev.yinqihui.net.cn:9500/group1/M00/01/18/oYYBAGEnZh2AdWRbAAAJaJkXTpU716.png'
},
{
itemName: '账户安全',
imgUrl:
'http://appdev.yinqihui.net.cn:9500/group1/M00/01/18/oYYBAGEnZh2AfC-NAAAK2jLqbSE225.png'
},
{
itemName: '客服帮助',
imgUrl:
'http://appdev.yinqihui.net.cn:9500/group1/M00/01/18/oYYBAGEnZh2AIfYoAAAJwg-SOew188.png'
}
]

return defaultItems
}

export default {
name: 'lbp-grid',
extra: {
defaultStyle: {
width: 300,
height: 70
}
},
props: {
dataset: {
type: Array,
default: () => getDefaultItems()
},
columnSize: PropTypes.number({
defaultValue: 4,
label: '一行几列'
}),
imgHeight: PropTypes.number({
defaultValue: 24,
label: '图片高度'
}),
imgWidth: PropTypes.number({
defaultValue: 24,
label: '图片宽度'
}),
color: PropTypes.color(),
fontSize: PropTypes.number({
defaultValue: 12,
label: '字号(px)'
})
},
componentsForPropsEditor: {
},
mounted () {
},
methods: {
},
render () {
const imgStyle = {
height: this.imgHeight + 'px',
width: this.imgWidth + 'px'
}
const style = {
color: this.color,
fontSize: this.fontSize + 'px'
}
const { dataset } = this
return
{
dataset.map(item => (


{ item.itemName }

))
}

}
}

如果在项目中 src/components/core/plugins下面新增组件的话,需要注意什么?我随便copy其他组件的代码,也无法预览

解决了,需要重新 build 之后 再运行,然后把 当前那个页面删除了 重新建一个页面 ,再拖控件,就可以显示