在HBuilder X 开发小程序项目时,自定义组件出现的错误: Module build failed (from ./node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js): 15:04:06.283 语法错误: Unexpected digit after hash token (23:15)
<template>
<view class="my-search-container" :style="{'background-color':bgcolor}" @click="searchBoxHandler">
<view class="my-search-box" :style="{'border-radius':radius + 'px'}">
<!-- 使用uni-ui图标组件 -->
<uni-icons type="search" size="17"></uni-icons>
<text class="placeholder">搜索 </text>
</view>
</view>
</template>
<script>
export default {
name:"my-search",
props: {
//背景颜色
bgcolor:{
type:String,
default:' #005500'
},
//圆角尺寸
radius:{
type:Number,
default: 18
}
},
data() {
return {
}
},
methods:{
searchBoxHandler(){
console.log(1)
this.$emit('click')
}
}
}
</script>
<style lang="scss">
.my-search-container {
height: 50px;
// background-color:#005500;
display: flex;
align-items: center;
padding: 0 10px;
.my-search-box {
height: 36px;
background-color: #fff;
// border-radius: 18px;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
.placeholder {
font-size: 15px;
margin-left: 5px;
}
}
}
</style>
语法错误,找了很久没找到,其实就是定义的数据类型是字符串,然后写颜色的时候忘记加引号‘’
记录报错日常,下次别踩坑了!