F
F
fostsinger2018-07-30 16:33:12
Vue.js
fostsinger, 2018-07-30 16:33:12

Why doesn't it switch to another component?

<div class="box_profile">
      <div class="box_left">
        <a href="#">Settings</a>
        <a href="#" @click="switchActive('users')">Users</a>
        <a href="#"   @click="switchActive('history')" class="active">History</a> </div>
      <div class="box_right">
<components :is="users"> </components>

<script>
import users from "~/components/users.vue"
  import history from "~/components/history.vue"
 components: {
        users,
        history
      },
      data() {
        return {
          active: 'users',

        }
      },
methods: {
        switchActive: function(view) {
          this.active = view;
          console.log("ok")
        }
      },
    }
</script>
throws an error
Property or method "users" is not defined on the instance but referenced during render.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2018-07-30
@delphinpro

probably a typo here

<components :is="users"> </components>
<components :is="active"> </components>

Example jsfiddle.net/4813uLdj
.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question