The implementation method is divided into three steps:
<template> <el-table :data="tableData" border style="width: 100%"> <el-table-column fixed prop="date" label="Date" width="200"> </el-table-column> <el-table-column prop="state" label="Status" width="150"> </el-table-column> <el-table-column prop="name" label="Name" width="120"> <template slot-scope="scope"> <el-input placeholder="Please enter content" v-show="scope.row.show" v-model="scope.row.name"> </el-input> <span v-show="!scope.row.show">{{scope.row.name}} </span> </template> </el-table-column> <el-table-column prop="province" label="Province" width="120"> </el-table-column> <el-table-column prop="city" label="Urban area" width="120"> </el-table-column> <el-table-column prop="address" label="Address" width="300" :show-overflow-tooltip="true" > </el-table-column> <el-table-column prop="zip" label="zip code" width="120"> </el-table-column> <el-table-column fixed="right" label="operation" width="300"> <template slot-scope="scope"> <el-button @click="handleClick(scope.row)" type="text" size="small">View</el-button> <el-button @click="scope.row.show =true" type="text" size="small">Edit</el-button> <el-button @click="scope.row.show =false" type="text" size="small">Save</el-button> <el-button @click="changeStatus" type="text" size="small" v-if="btnStatus == 0">Enable</el-button> <el-button @click="changeStatus" type="text" size="small" v-show="btnStatus == 1">Disable</el-button> </template> </el-table-column> </el-table> </template> <script> export default { methods: { handleClick(row) { console.log(row); }, changeStatus(){ this.btnStatus = this.btnStatus === 0 ? 1 : 0; } }, data() { return { btnStatus: 0, tableData: [{ date: '2016-05-02', name: 'Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu Wang Xiaohu', province: 'Shanghai', city: 'Putuo District', address: 'No. 1518, Jinshajiang Road, Putuo District, Shanghai No. 1518, Jinshajiang Road, Putuo District, Shanghai', zip: 200333, show:true }, { date: '2016-05-04', name: 'Wang Xiaohu', province: 'Shanghai', city: 'Putuo District', address: 'No. 1517, Jinshajiang Road, Putuo District, Shanghai', zip: 200333, show:true }] } } } </script> In addition, please note that the default value of the button should be placed under data, as shown in Figure 1. It cannot be placed in a table, otherwise the button will not be displayed and an error will be reported. Figure 2: Property or method "btnStatus" is not defined on the instance but referenced during render. The reason for this error is: "btnStatus" is used in the template or in the method, but it is not defined in the data. This is the end of this article about the button becoming disabled after the click toggle button function in vue is enabled. For more relevant vue click toggle button content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of mysql backup and recovery
>>: Idea deployment tomcat service implementation process diagram
Disable Build Partition expressions do not suppor...
If you want to wrap the text in the textarea input...
This article example shares the specific code of ...
This is my first blog. It’s about when I started ...
Table of contents 1. Use scripts to encrypt TLS f...
In a complex table structure, some cells span mul...
1. RTMP RTMP streaming protocol is a real-time au...
Table of contents 1. Overview 1.1 Creating a func...
To solve the problem that Deepin cannot start Goo...
This article uses examples to illustrate the prin...
This article shares the MySQL backup script for y...
1. MySQL User Management [Example 1.1] Log in to ...
1. Vue--The first vue-cli program The development...
Preface: When you execute a SQL statement in MySQ...
First, let me explain the version of MySQL: mysql...