Message & Notice support SSR
This commit is contained in:
parent
9b2034a5ab
commit
e8e1677b47
3 changed files with 46 additions and 19 deletions
|
@ -27,7 +27,8 @@ module.exports = merge(webpackBaseConfig, {
|
|||
resolve: {
|
||||
alias: {
|
||||
iview: '../../src/index',
|
||||
vue: 'vue/dist/vue.js'
|
||||
// vue: 'vue/dist/vue.js'
|
||||
vue: 'vue/dist/vue.runtime.js'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
|
|
|
@ -1,21 +1,44 @@
|
|||
<template>
|
||||
<i-button type="primary" @click.native="time">打开提醒</i-button>
|
||||
<div>
|
||||
<p>带描述信息</p>
|
||||
<Button @click="info(false)">消息</Button>
|
||||
<Button @click="success(false)">成功</Button>
|
||||
<Button @click="warning(false)">警告</Button>
|
||||
<Button @click="error(false)">错误</Button>
|
||||
<p>仅标题</p>
|
||||
<Button @click="info(true)">消息</Button>
|
||||
<Button @click="success(true)">成功</Button>
|
||||
<Button @click="warning(true)">警告</Button>
|
||||
<Button @click="error(true)">错误</Button>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
time () {
|
||||
this.$Notice.open({
|
||||
info (nodesc) {
|
||||
this.$Notice.info({
|
||||
title: '这是通知标题',
|
||||
desc: '这条通知不会自动关闭,需要点击关闭按钮才可以关闭。'
|
||||
desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
|
||||
});
|
||||
},
|
||||
success (nodesc) {
|
||||
this.$Notice.success({
|
||||
title: '这是通知标题',
|
||||
desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
|
||||
});
|
||||
},
|
||||
warning (nodesc) {
|
||||
this.$Notice.warning({
|
||||
title: '这是通知标题',
|
||||
desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
|
||||
});
|
||||
},
|
||||
error (nodesc) {
|
||||
this.$Notice.error({
|
||||
title: '这是通知标题',
|
||||
desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
|
||||
});
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.$Notice.config({
|
||||
top: 150,
|
||||
duration: 30
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -10,15 +10,18 @@ Notification.newInstance = properties => {
|
|||
props += ' :' + camelcaseToHyphen(prop) + '=' + prop;
|
||||
});
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = `<notification${props}></notification>`;
|
||||
document.body.appendChild(div);
|
||||
|
||||
const notification = new Vue({
|
||||
el: div,
|
||||
const Instance = new Vue({
|
||||
data: _props,
|
||||
components: { Notification }
|
||||
}).$children[0];
|
||||
render (h) {
|
||||
return h(Notification, {
|
||||
props: _props
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
const component = Instance.$mount();
|
||||
document.body.appendChild(component.$el);
|
||||
const notification = Instance.$children[0];
|
||||
|
||||
return {
|
||||
notice (noticeProps) {
|
||||
|
|
Loading…
Add table
Reference in a new issue