vue之字符串、數(shù)組之間的相互轉(zhuǎn)換方式
更新時間:2023年07月05日 14:41:27 作者:new-lijiabin
這篇文章主要介紹了vue之字符串、數(shù)組之間的相互轉(zhuǎn)換方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
vue字符串、數(shù)組之間的相互轉(zhuǎn)換
字符串如何轉(zhuǎn)數(shù)組
str.split(';'); //以分號拆分字符串數(shù)組如何轉(zhuǎn)字符串
arr.join(';'); //把數(shù)組項拼接成字符串,并以分號隔開。默認(rèn)情況下是以逗號隔開vue element項目中數(shù)組轉(zhuǎn)字符串 字符串轉(zhuǎn)數(shù)組
數(shù)組轉(zhuǎn)字符串
備注(主要是這句):
this.modifyForm.prefecture =this.modifyForm.prefecture.toString()
async handleAdclick() {
this.modifyForm.prefecture = this.modifyForm.prefecture
.toString()
.replace(/,/gi, '|')
const result = await addCustomer(this.modifyForm)
if (result.code === 200) {
/* 添加完置空表單 */
this.modifyForm = {
address: '',
age: '',
avatar: '',
mobile: '',
memo: '',
conditionTags: '',
email: '',
employeeId: '',
enterpriseWechatTags: '',
name: '',
rfmtags: '',
sex: true,
sources: '',
wxNickname: '',
prefecture: ''
}
this.$message.success('添加成功')
this.$router.go(-1)
} else {
this.$message.error('添加失敗')
}
}字符串轉(zhuǎn)數(shù)組
備注(主要是這句):
this.distrubuteForm.ids = this.writerAnotherId.split(‘,')
(我這里有個字段賦值,對應(yīng)好你的字段即可)
async handleAdclick() {
this.distrubuteForm.ids = this.writerAnotherId.split(',')
const result = await distrubuteCustom(this.distrubuteForm)
if (result.code === 200) {
/* 添加完置空表單 */
this.distrubuteForm = {
crmId: '',
followUpUserId: '',
ids: [],
optUserId: ''
}
this.$message.success('分配成功')
this.distributionDialogVisible = false
this.getList()
} else {
this.$message.error('分配失敗')
}
}總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Vue2過渡標(biāo)簽transition使用動畫方式
這篇文章主要介紹了Vue2過渡標(biāo)簽transition使用動畫方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-07-07
Vue3如何理解ref toRef和toRefs的區(qū)別
本文主要介紹了Vue3如何理解ref toRef和toRefs的區(qū)別,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-12-12
詳解Vue自定義指令如何實現(xiàn)處理圖片加載失敗的碎圖
這篇文章主要介紹了詳解Vue自定義指令如何實現(xiàn)處理圖片加載失敗的碎圖,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧2023-02-02

