csonchen / wxParse

微信小程序富文本解析
https://csonchen.github.io/wxParse/
MIT License
274 stars 41 forks source link

重新设置html后图片一直会显示loading状态 #55

Open Vinsurs opened 2 years ago

Vinsurs commented 2 years ago

大佬, 代码如下:

const Page: FC = () => {
    const html = `
        <h2 style="color: red;">文章标题</h2>
        <main>
            <article>文章内容</article>
            <img src="https://storage.360buyimg.com/cjj-pub-images/taro-daily.jpeg" alt="图片" width="100%" height="auto" />
            <p>这是很长一段文字</p>
        </main>
    `
    const [htmlText, setHtmlText] = useState(html)
    const handleClick = () => {
        setHtmlText(html + `<footer>这里是页脚</footer>`)
    }
return (
        <View>
            <View>我的</View>
            <View>
                <wxParse nodes={htmlText} />
            </View>
            <Button type='primary' onClick={handleClick}>改变html</Button>
        </View>
    )
}
export default Page

当我点击按钮改变html的时候,图片一直会显示loading状态而不显示出图片来,麻烦看下这个bug呢?开源不易 ,万分感谢!

csonchen commented 2 years ago

大佬, 代码如下:

const Page: FC = () => {
    const html = `
        <h2 style="color: red;">文章标题</h2>
        <main>
            <article>文章内容</article>
            <img src="https://storage.360buyimg.com/cjj-pub-images/taro-daily.jpeg" alt="图片" width="100%" height="auto" />
            <p>这是很长一段文字</p>
        </main>
    `
    const [htmlText, setHtmlText] = useState(html)
    const handleClick = () => {
        setHtmlText(html + `<footer>这里是页脚</footer>`)
    }
return (
        <View>
            <View>我的</View>
            <View>
                <wxParse nodes={htmlText} />
            </View>
            <Button type='primary' onClick={handleClick}>改变html</Button>
        </View>
    )
}
export default Page

当我点击按钮改变html的时候,图片一直会显示loading状态而不显示出图片来,麻烦看下这个bug呢?开源不易 ,万分感谢!

@Vinsurs 控制台有报错吗

Vinsurs commented 2 years ago

@csonchen 没报错信息哦, 就一直是loading状态,但是点击它预览的时候是有图片出来的