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
CentOS official website address https://www.cento...
question When I was writing a project function to...
Table of contents Preparation Deployment process ...
Docker is an open source project that provides an...
I was watching Tik Tok some time ago and thought ...
I just happened to encounter this small requireme...
Table of contents Is setState synchronous or asyn...
Table of contents Preface How to encapsulate a To...
Recently, when I was writing a WeChat applet, the...
1. Absolute path First of all, on the local compu...
In the front-end and back-end separation developm...
Source: http://www.ruoyi.vip/ import Vue from ...
Table of contents 1. Keywords 2. Deconstruction 3...
Table of contents 1. Data Type 1.1 Why do we need...
Write configuration files in server.xml and conte...