Home > Web Front-end > JS Tutorial > How to make Tab component using vue

How to make Tab component using vue

亚连
Release: 2018-06-22 14:48:52
Original
1409 people have browsed it

This article mainly introduces you to the relevant information about using vue components to customize v-model to implement a Tab component. The article introduces it in detail through sample code, which has certain reference learning value for everyone's study or work. Friends who need it, please follow the editor to learn together.

Preface

I have been learning vue recently. I saw custom components today. I struggled with them for a while and then suddenly realized...Official tutorial written It's not very detailed, so I decided to summarize it. Not much to say below, let’s take a look at the detailed introduction.

Effect

Let us take a look at the effect of the example first!


v-model

We know that v-model is an instruction in vue. vue’s v-model is a very powerful instruction, which can automatically make native The value of the form component is automatically bound to the value you choose. It can be used on the input tag to do two-way binding of data, like this:

<input v-model="tab">
Copy after login

v-model is actually a syntactic sugar. You can also write like this:

<input :value="tab" :input="tab = $event.target.value">
Copy after login

As you can see, it is just passing in a parameter: value and monitoring an event @input.

If you have such a requirement, you need to use v-model on your own component, like this:

<Tab v-model="tab"></Tab>
Copy after login

How to implement it?

Now that we know that v-model is syntax sugar, first, we can know the parameters obtained within the component.

<!-- Tab.vue -->
<template>
<p class="tab">
<p>You can try to print this value
Copy after login

The above is the detailed content of How to make Tab component using vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template