how can i set a document.title according to a condition in mounted? (vue.js)

I wanted the title to be set as soon as the page loaded, but instead nothing happens and just the same title ‘localhost’ remains.

<script>
export default {
  name: '',
  mounted() {
    this.setTitle();
  },
  methods: {
    setTitle() {
      let index = localStorage.getItem('index');
      if (index) {
        document.title = "Test";
      }
    }
  }
}
</script>