vue中设定html颜色格式报错:[Vue warn]: Failed to resolve directive: html:

    <div id="app-2">
        <p>
            using: {{ message }}
        </p>
<!--        <p>this whould be red: <span v-html: style="color: red">{{ rawHtml }}</span> </p>-->//这个是报错原因,已注释
        <p>this will be blue: <span v-html="message" style="color: blue"></span> </p>
        <p>this will be red: <span v-html="message" style="color: red"></span> </p>
    </div>
    <script>
         'use strict'
        let app2 = new Vue({
            el: '#app-2',
            data: {
                message: 'html style'
            }
        })
    </script>

 

  显示结果:

using: html style

this will be blue: html style

this will be red: html style

posted @ 2022-03-03 09:04  下雨天的伞  阅读(792)  评论(0)    收藏  举报