vue項目無法刪除的問題及解決
vue項目無法刪除
問題
今天刪除本地的vue項目,一直提示“操作無法完成,因為其中的文件夾或文件已在另一個程序組打開,請關(guān)閉該文件夾或文件,然后重試”。
但是相關(guān)的軟件我都關(guān)閉了,還是不行。如圖
解決
我們ctrl+alt+delete打開任務(wù)管理器,點擊詳細信息,找到node.exe
右擊選擇結(jié)束任務(wù),然后點擊結(jié)束進程,然后就可以成功刪除項目了。
vue新增與刪除問題
<template> ? <div> ? ? <ul v-for="(item , index) in list" :key="index"> ? ? ? <li> ? ? ? ? {{item.serial}}--- ? ? ? ? <button @click="remove(index)">刪除</button> ? ? ? </li> ? ? </ul> ? ? <input type="text" v-model="serial" /> ? ? <input type="button" value="點擊添加" @click="getserial" /> ? </div> </template>
<script> export default { ? data() { ? ? return { ? ? ? list: [ ? ? ? ? { serial: 1 }, ? ? ? ? { serial: 2 }, ? ? ? ? { serial: 3 }, ? ? ? ? { serial: 4 }, ? ? ? ? { serial: 5 } ? ? ? ], ? ? ? serial: "" ? ? }; ? }, ? methods: { ? ? getserial() { ? ? ? this.list.push({ ? ? ? ? serial: this.serial ? ? ? }); ? ? ? this.serial = ""; ? ? }, ? ? //通過索引刪除數(shù)組 ? ? remove(index) { ? ? ? //splice 操作數(shù)組的方法 ? ? ? this.list.splice(index, 1); ? ? } ? } }; </script> ? <style> </style>
html:
<template> ? <el-main> ? ? <el-col :span="24" class="warp-main" v-loading=""> ? ? ? <el-form :inline="true" class="demo-form-inline" v-for="(item, i) in FormArr" :key="i"> ? ? ? ? <el-form-item label="樣例"> ? ? ? ? ? <el-input v-model="item.value"></el-input> ? ? ? ? </el-form-item> ? ? ? ? <el-button type="primary" @click="Delete(item.index)">刪除</el-button> ? ? ? </el-form> ? ? ? <el-button type="primary" @click="AddForm">增加更多</el-button> ? ? </el-col> ? </el-main> </template>
邏輯:
<script> export default { ? data () { ? ? return { ? ? ? FormArr: [ ? ? ? ? { ? ? ? ? ? index: 0, ? ? ? ? ? value: '' ? ? ? ? } ? ? ? ] ? ? } ? }, ? methods: { ? ? AddForm () { ? ? ? this.FormArr.push({ ? ? ? ? index: this.FormArr.length, ? ? ? ? value: '' ? ? ? }) ? ? ? console.log(this.FormArr) ? ? }, ? ? Delete (index) { ? ? ? this.FormArr.splice(index, 1) ? ? ? for (let i in this.FormArr) { ? ? ? ? this.FormArr[i].index = i ? ? ? } ? ? } ? } } </script>
注釋:
1.通過對數(shù)組的操作,進行添加和刪除;
2.這里應(yīng)注意index這個索引,用于刪除時,知道刪的是哪一個值;
3.刪完對應(yīng)的值,要對數(shù)組的index這個索引重組,否則再刪除時會出錯;
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue如何把字符串中的所有@內(nèi)容,替換成帶標(biāo)簽的
這篇文章主要介紹了vue如何把字符串中的所有@內(nèi)容,替換成帶標(biāo)簽的問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-10-10vue?this.$router.go(-1);返回時如何帶參數(shù)
這篇文章主要介紹了vue?this.$router.go(-1);返回時如何帶參數(shù)問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-12-12vue+elementUI-el-table實現(xiàn)動態(tài)顯示隱藏列方式
這篇文章主要介紹了vue+elementUI-el-table實現(xiàn)動態(tài)顯示隱藏列方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-01-01