Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mes-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周远喜
mes-ui
Commits
de163959
Commit
de163959
authored
May 08, 2020
by
周远喜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ok
parent
d00ed736
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
184 additions
and
1 deletion
+184
-1
remote.vue
components/page/remote.vue
+135
-0
nuxt.config.js
nuxt.config.js
+1
-0
test.vue
pages/test.vue
+1
-1
com.vue
pages/test/com.vue
+21
-0
user.txt
static/user.txt
+26
-0
No files found.
components/page/remote.vue
0 → 100644
View file @
de163959
<
template
>
<div
class=
"remote"
>
<component
:is=
"currentView"
v-bind=
"$props"
@
onChange=
"hi"
/>
</div>
</
template
>
<
script
>
import
Axios
from
"axios"
;
// import '@/utils/less.min';
export
default
{
props
:
{
url
:
{
type
:
String
,
default
()
{
return
null
;
}
}
},
data
()
{
return
{
resData
:
null
,
cssId
:
null
};
},
computed
:
{
currentView
()
{
if
(
!
this
.
resData
)
return
{
template
:
"<div class='remoteInfo'>正在加载中。。。</div>"
};
const
tplData
=
this
.
resolveStr
(
this
.
resData
);
let
ponentObj
=
new
Function
(
`return
${
tplData
.
sctipts
.
slice
(
tplData
.
sctipts
.
indexOf
(
"{"
),
tplData
.
sctipts
.
lastIndexOf
(
"}"
)
+
1
)}
`
)();
ponentObj
.
template
=
tplData
.
templates
;
// this.$el.setAttribute('class',`remote css${this.cssId}`);
// if(!document.querySelector(`style[id=css${this.cssId}]`)){//防止重复创建
// let cssStr = `
// .css${this.cssId}{
// ${tplData.styles}
// }
// `;
// this.resolveCss(cssStr);
// }
return
ponentObj
;
}
},
watch
:
{
url
()
{
this
.
getData
();
}
},
mounted
()
{
this
.
getData
();
},
methods
:
{
hi
(
v
){
alert
(
v
)
},
getId
()
{
var
d
=
new
Date
().
getTime
();
var
uid
=
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
.
replace
(
/
[
xy
]
/g
,
function
(
c
)
{
var
r
=
(
d
+
Math
.
random
()
*
16
)
%
16
|
0
;
d
=
Math
.
floor
(
d
/
16
);
return
(
c
==
"x"
?
r
:
(
r
&
0x3
)
|
0x8
).
toString
(
16
);
}
);
return
uid
;
},
resolveCss
(
lessInput
)
{
less
.
render
(
lessInput
).
then
(
function
(
output
)
{
let
style
=
document
.
createElement
(
"style"
);
style
.
setAttribute
(
"type"
,
"text/css"
);
style
.
setAttribute
(
"id"
,
"css"
+
this
.
cssId
);
if
(
style
.
styleSheet
)
// IE
style
.
styleSheet
.
cssText
=
output
.
css
;
else
{
// w3c
var
cssText
=
document
.
createTextNode
(
output
.
css
);
style
.
appendChild
(
cssText
);
}
var
heads
=
document
.
getElementsByTagName
(
"head"
);
if
(
heads
.
length
)
heads
[
0
].
appendChild
(
style
);
else
document
.
documentElement
.
appendChild
(
style
);
}.
bind
(
this
)
);
},
resolveStr
(
str
)
{
return
{
templates
:
str
.
match
(
/<template>
([\s\S]
*
)
<
\/
template>/
)[
1
],
sctipts
:
str
.
match
(
/<script.*>
([\s\S]
*
)
<
\/
script>/
)[
1
],
// styles: str.match(/
<
style
.
*>
([
\
s
\
S
]
*
)
<
\
/
style
>
/
)[
1
]
};
},
async
getData
()
{
// let remoteData = this.$store.getters.getRemoteByUrl(this.url);
// if(remoteData){
// this.resData = remoteData.resData;
// this.cssId = remoteData.cssId;
// }else{
if
(
this
.
$props
.
url
)
{
const
res
=
await
Axios
.
get
(
this
.
$props
.
url
);
// this.cssId = this.getId();
this
.
resData
=
res
.
data
;
console
.
log
(
this
.
resData
)
}
// this.$store.dispatch('doAction',{
// event:'addRemote',
// data:{url:this.url,cssId:this.cssId,resData:this.resData}
// });
// }
}
// async getData(){
// let remoteData = this.$store.getters.getRemoteByUrl(this.url);
// if(remoteData){
// this.resData = remoteData.resData;
// this.cssId = remoteData.cssId;
// }else{
// const res = await Axios.get(this.$props.url);
// this.cssId = this.getId();
// this.resData = res.data;
// this.$store.dispatch('doAction',{
// event:'addRemote',
// data:{url:this.url,cssId:this.cssId,resData:this.resData}
// });
// }
// }
}
};
</
script
>
\ No newline at end of file
nuxt.config.js
View file @
de163959
...
...
@@ -105,6 +105,7 @@ export default {
}
},
extend
(
config
,
ctx
)
{
config
.
resolve
.
alias
[
'vue$'
]
=
'vue/dist/vue.esm.js'
// config.resolve.alias['_c']=path.resolve(__dirname, 'components')
// config.module.rules.push({
// enforce:'pre',
...
...
pages/test.vue
View file @
de163959
...
...
@@ -20,7 +20,7 @@
<Menu
mode=
"horizontal"
active-name=
"1"
>
<div
class=
"layout-assistant"
>
<MenuItem
name=
"1"
to=
"/test/user"
>
人员选择
</MenuItem>
<MenuItem
name=
"2"
>
Option 2
</MenuItem>
<MenuItem
name=
"2"
to=
"/test/com"
>
异步组件
</MenuItem>
<MenuItem
name=
"3"
>
Option 3
</MenuItem>
</div>
</Menu>
...
...
pages/test/com.vue
0 → 100644
View file @
de163959
<
style
lang=
"less"
>
</
style
>
<
template
>
<div
class=
"layout"
>
<Button
@
click=
"load()"
>
异步组件
</Button>
<Remote
url=
"/user.txt"
@
onChange=
"hi"
></Remote>
</div>
</
template
>
<
script
>
import
Remote
from
"@/components/page/remote"
export
default
{
components
:{
Remote
},
methods
:{
hi
(
v
){
alert
(
v
)
}
}
}
</
script
>
\ No newline at end of file
static/user.txt
0 → 100644
View file @
de163959
<template>
<div style="padding:50px;">
<UserSelect v-model="user" :multiple="true" theme="list"/>
<!-- <DepartmentSelect v-model="dep" /> -->
<Button @click="setUser">Set</Button>{{dep}}
{{user}}
</div>
</template>
<script>
export default {
data(){
return {
dep:39,
user:[21,22,23]
}
},
methods:{
setUser(){
this.user=[25]
this.$emit("onChange",25)
}
}
}
</script>
<style lang="less"></style>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment