美文网首页
HBuilder 运行小程序常见错误

HBuilder 运行小程序常见错误

作者: 八妹sss | 来源:发表于2020-11-10 10:26 被阅读0次

    1、报错 × initialize,开发者工具的端口和运行时的的端口号不一致导致

    解决方法:在开发者工具:设置->安全 重新打开一下服务端口号,HBuilder重新运行一下代码


    image.png

    2、报错 × open IDE,需要配置微信小程序AppID和uni-app应用标识(AppID)

    image.png image.png

    3、uni-app 背景图无法加载本地图片,解决方法动态加载

    报错:


    image.png

    解决方法:

    // 方法一:
    
    <template>
        <view class="index" :style="{backgroundImage:`url(${indexBackgroundImage})`,backgroundSize: 'cover'}">
            <!--你的内容-->
        </view>
    </template>
    <script>
        import indexBackgroundImage from "@/static/img/account_index.jpg"
        export default {
            data() {
                return {
                    indexBackgroundImage:indexBackgroundImage
                }
            },
            methods: {}
        }
    </script>
    
    // 方法二:
    <div :style="{backgroundImage: `url(${require('../../static/img/meeting_bg@2x.png')})`}" class="default-cover"></div>
    

    相关文章

      网友评论

          本文标题:HBuilder 运行小程序常见错误

          本文链接:https://www.haomeiwen.com/subject/wwvdbktx.html