-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
155 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,5 @@ app.use(ElementPlus); | |
|
||
// mount | ||
app.mount('#app'); | ||
|
||
window.app1 = app; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Created by Liu.Jun on 2020/4/25 14:45. | ||
*/ | ||
|
||
import { resolveComponent as _resolveComponent } from 'vue'; | ||
|
||
// 内部使用 . ,配置数据key不能出现. | ||
const pathSeparator = '.'; | ||
|
||
// nodePath 转css类名 | ||
export function nodePath2ClassName(path) { | ||
const rootPathName = '__pathRoot'; | ||
return path ? `${rootPathName}.${path}`.replace(/\./g, '_') : rootPathName; | ||
} | ||
|
||
// 是否为根节点 | ||
export function isRootNodePath(path) { | ||
return path === ''; | ||
} | ||
|
||
// 计算当前节点path | ||
export function computedCurPath(prePath, curKey) { | ||
return prePath === '' ? curKey : [prePath, curKey].join(pathSeparator); | ||
} | ||
|
||
// 删除当前path值 | ||
export function deletePathVal(vueData, name) { | ||
// Vue.delete(vueData, name); | ||
} | ||
|
||
// 设置当前path值 | ||
export function setPathVal(obj, path, value) { | ||
// Vue.set ? | ||
const pathArr = path.split(pathSeparator); | ||
for (let i = 0; i < pathArr.length; i += 1) { | ||
if (pathArr.length - i < 2) { | ||
// 倒数第一个数据 | ||
// obj[pathArr[pathArr.length - 1]] = value; | ||
// Vue.set(obj, pathArr[pathArr.length - 1], value); | ||
break; | ||
} | ||
obj = obj[pathArr[i]]; | ||
} | ||
} | ||
|
||
// 获取当前path值 | ||
export function getPathVal(obj, path, leftDeviation = 0) { | ||
const pathArr = path.split(pathSeparator); | ||
|
||
for (let i = 0; i < pathArr.length - leftDeviation; i += 1) { | ||
// 错误路径或者undefined中断查找 | ||
if (obj === undefined) return undefined; | ||
obj = pathArr[i] === '' ? obj : obj[pathArr[i]]; | ||
} | ||
return obj; | ||
} | ||
|
||
// path 等于props | ||
export function path2prop(path) { | ||
return path; | ||
} | ||
|
||
export function resolveComponent(component) { | ||
if (typeof component === 'string') return _resolveComponent(component); | ||
|
||
return component; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters