[toc]
### 1.實現點擊復選框展示對應的操作按鈕
```
//index.vue
computed : {
checkList(){
return this.list.filter(item=>item.checked)
},
checkedAllStatus(){
return this.checkList.length === this.list.length
},
//根據選中的復選框個數控制操作按鈕
checkedCount(){
return this.checkList.length
}
}
<div class="d-flex top-button align-items-center">
<Button type="primary" icon="ios-search" class="mr-2">上傳</Button>
<Button icon="ios-search" class="mr-2">新建文件夾</Button>
<Button icon="ios-search" v-if="checkedCount" class="mr-2">下載</Button>
<Button icon="ios-search" v-if="checkedCount == 1" class="mr-2">分享</Button>
<Button icon="ios-search" v-if="checkedCount == 1" class="mr-2">重命名</Button>
<Button icon="ios-search" v-if="checkedCount" class="mr-2">刪除</Button>
<Input class="ml-auto top-search" search enter-button placeholder="請輸入關鍵詞" />
</div>
```
### 2. 實現重名名功能
```
//media-list.vue
<DropdownItem @click.native="rename">重命名</DropdownItem>
//重命名
rename() {
this.value = this.item.name
this.$Modal.confirm({
render: (h) => {
return h('Input', {
props: {
value: this.value,
autofocus: true,
placeholder: '請填寫新名稱...'
},
on: {
input: (val) => {
console.log(val)
this.value = val;
}
}
})
},
onOk : ()=>{
this.$emit("on-event",{
type : "rename",
index: this.index,
value : this.value
})
}
})
}
//index.vue
handleEvent(e) {
console.log(e.value)
switch (e.type) {
case "delete":
this.list.splice(e.index, 1);
this.$Message.success("刪除成功")
break;
case "checked":
this.list[e.index].checked = e.value
break;
case "rename" :
this.list[e.index].name = e.value
default:
break;
}
},
```
### 3. 點擊操作的重命名按鈕,實現文件重命名功能(對上一個重命名功能優化)
```
//media-list.vue
//重命名
rename() {
this.$emit("on-event",{
type : "rename",
index: this.index
})
}
//index.vue
<Button icon="ios-search" @click="rename(false)" v-if="checkedCount == 1" class="mr-2">重命名</Button>
//重命名
rename(index = false){
let item = index !==false ?this.list[index] : this.checkList[0]
let value = item.name
this.$Modal.confirm({
render: (h) => {
return h('Input', {
props: {
value: value,
autofocus: true,
placeholder: '請填寫新名稱...'
},
on: {
input: (val) => {
value= val;
}
}
})
},
onOk : ()=>{
item.name = value
}
})
}
handleEvent(e) {
console.log(e.value)
switch (e.type) {
case "delete":
this.list.splice(e.index, 1);
this.$Message.success("刪除成功")
break;
case "checked":
this.list[e.index].checked = e.value
break;
case "rename" :
this.rename(e.index)
default:
break;
}
},
```
- 第一章 VUE-CLI+IVIEW進行項目初始化
- 1.1 使用vue-cli4創建項目
- 1.2 引入iview組件庫
- 1.3 引入bootstrap4和圖標庫
- 1.4 安裝和配置vue-router
- 第二章 pc端登錄頁開發
- 2.1 pc端登錄頁開發(一)
- 2.2 pc端登錄頁開發(二)
- 2.3 pc端登錄頁開發(三)
- 第三章 pc端全局布局開發
- 3.1 pc端全局布局開發(一)
- 3.2 pc端全局布局開發(二) 頂部導航
- 第四章 pc端側邊欄開發
- 4.1 pc端側邊欄開發(一) 菜單
- 4.2 pc端側邊欄開發(二) 容量提示
- 第五章 pc端文件列表開發
- 5.1 pc端文件列表開發(一) 操作條
- 5.2 pc端文件列表開發(二) 列表(1)
- 5.3 pc端文件列表開發(三) 列表(2)
- 第六章 封裝多功能文件列表組件
- 6.1 封裝文件列表組件(一)
- 6.2 封裝文件列表組件(二) 刪除
- 6.3 封裝文件列表組件(三) 多選操作
- 6.4 封裝文件列表組件(四) 重命名
- 6.5 封裝文件列表組件(五) 圖片預覽
- 第七章 前端數據交互開發
- 7.1 pc端交互-引入axios和vuex
- 7.2 pc端交互-注冊登錄
- 7.3 pc端交互-初始化和退出登錄
- 7.4 pc端交互-攔截器完善
- 7.5 權限驗證
- 7.6 pc端交互-獲取文件列表
- 7.7 pc端交互-創建文件夾
- 7.8 上傳文件
- 7.9 pc端交互-文件重命名
- 7.10 pc端交互-批量刪除
- 7.11 pc端交互-搜索文件
- 7.12 pc端交互-切換目錄
- 7.13 pc端交互-優化體驗和篩選類型
- 7.14 pc端交互-下載文件
- 7.15 pc端交互-生成分享鏈接
- 7.16 pc端交互-我的分享列表
- 7.17 pc端交互-查看分享
- 7.18 pc端交互-保存我的網盤
- 第八章 項目打包與部署
- 8.1 部署前環境搭建
- 8.2 部署pc端部分