How can I bind the html <title> content in vuejs?

后端 未结 5 488
后悔当初
后悔当初 2020-11-29 00:19

I\'m trying a demo on vuejs. Now I want the html title to bind a vm field.

The below is what I tried:

index.html



        
5条回答
  •  情歌与酒
    2020-11-29 00:41

    This answer is for vue 1.x

    using requirejs.

    define([
      'https://cdn.jsdelivr.net/vue/latest/vue.js'
    ], function(Vue) {
      var vm = new Vue({
        el: 'html',
        data: {
          hello: 'Hello world'
        }
      });
    });
    
    
    
    
      {{ hello }}
      
    
    
    
      {{ hello }}
      
    
    
    

    you can do it like this using the ready function to set the initial value and watch to update when the data changes.

    
    
    Replace Me
    
    
    
    
    

    also i tried this based on your original code and it works

    
    
    {{ title }}
    
    
    
    
    

提交回复
热议问题