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

后端 未结 5 493
后悔当初
后悔当初 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:48

    Title and meta tags can be edited and updated asynchronously.

    You can use state management, create a store for SEO using vuex and update each part accordingly.

    Or you can update the element by yourself easily

    created: function() {  
    
      ajax().then(function(data){
         document.title = data.title  
         document.head.querySelector('meta[name=description]').content = data.description
      })
    
    }
    

提交回复
热议问题