将 vue 挂在 window 对象上,实现能调用 elementUI 的组件

  • html 部分:
<div id="sample">
</div>
  • js 部分(将js代码放在 body 的 onload事件中: <body onload="init()">):
function init() {
  window.vue = new Vue({
                el: '#sample',
                data: function () {
                    return {
                    }
                },
                methods: {
                }
            })
  window.vue.$message('message')
}
原文地址:https://www.cnblogs.com/cag2050/p/8424318.html