首页 > v-html怎么实现动态绑定

v-html怎么实现动态绑定

@尤雨溪

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="vue.js"></script>
    <script>
        var vm = new Vue({
            data: {
                str: "str",
                html: "html"
            },
            methods: {
                click: function () {
                    console.log("xxx")
                }
            }
        })
        window.onload = function () {
            vm.$mount(document.body)
            setTimeout(function () {
                vm.html = '<div v-text="str"></div>'
            }, 1000)
            setTimeout(function () {
                vm.html = '<button v-el:button v-on:click="click">click me</button>'
            }, 2000)
        }
    </script>
</head>
<body v-html="html">
</body>
</html>
【热门文章】
【热门文章】