如何在组件 VueJS 中初始化小部件?

How to initialize widget in component VueJS?

一样,但不幸的是出了点问题。 我想初始化 this 代码。
这是我的代码:

<template>
  <div id="vk_share_button"></div>
</template>

<script>
    export default {
      methods:{
        start(){
          document.getElementById('vk_share_button').innerHTML =
            VK.Share.button('example.com', {type: 'link'});
        }
      },
      created(){
          VK.ready(this.start());
      }
    }
</script>

我也尝试使用:VK.Share.ready/VK.Share.button.ready,但我得到了同样的错误:

Cannot set property 'innerHTML' of null

我以为没有加载外部代码,但我不确定。我哪里出错了?

尝试使用 mounted block instead of created 块,因为挂载块是 在实例刚刚挂载后调用,其中 el 被新创建的 vm.$el` 替换,如下所示:

<script>
    export default {
      methods:{
        start(){
          document.getElementById('vk_share_button').innerHTML =
            VK.Share.button('example.com', {type: 'link'});
        }
      },
      mounted(){
          VK.ready(this.start());
      }
    }
</script>