Commit e8e1677b47576ae728ff0d77a8e3d229f2fb7624

Authored by Aresn
1 parent 9b2034a5

Message & Notice support SSR

build/webpack.dev.config.js
... ... @@ -27,7 +27,8 @@ module.exports = merge(webpackBaseConfig, {
27 27 resolve: {
28 28 alias: {
29 29 iview: '../../src/index',
30   - vue: 'vue/dist/vue.js'
  30 + // vue: 'vue/dist/vue.js'
  31 + vue: 'vue/dist/vue.runtime.js'
31 32 }
32 33 },
33 34 plugins: [
... ...
examples/routers/notice.vue
1 1 <template>
2   - <i-button type="primary" @click.native="time">打开提醒</i-button>
  2 + <div>
  3 + <p>带描述信息</p>
  4 + <Button @click="info(false)">消息</Button>
  5 + <Button @click="success(false)">成功</Button>
  6 + <Button @click="warning(false)">警告</Button>
  7 + <Button @click="error(false)">错误</Button>
  8 + <p>仅标题</p>
  9 + <Button @click="info(true)">消息</Button>
  10 + <Button @click="success(true)">成功</Button>
  11 + <Button @click="warning(true)">警告</Button>
  12 + <Button @click="error(true)">错误</Button>
  13 + </div>
3 14 </template>
4 15 <script>
5 16 export default {
6 17 methods: {
7   - time () {
8   - this.$Notice.open({
  18 + info (nodesc) {
  19 + this.$Notice.info({
9 20 title: '这是通知标题',
10   - desc: '这条通知不会自动关闭,需要点击关闭按钮才可以关闭。'
  21 + desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
  22 + });
  23 + },
  24 + success (nodesc) {
  25 + this.$Notice.success({
  26 + title: '这是通知标题',
  27 + desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
  28 + });
  29 + },
  30 + warning (nodesc) {
  31 + this.$Notice.warning({
  32 + title: '这是通知标题',
  33 + desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
  34 + });
  35 + },
  36 + error (nodesc) {
  37 + this.$Notice.error({
  38 + title: '这是通知标题',
  39 + desc: nodesc ? '' : '这里是通知描述这里,是通知描述这里是通知描述这里,是通知描述这里,是通知描述这里是通知描述这里是通知描述'
11 40 });
12 41 }
13   - },
14   - mounted () {
15   - this.$Notice.config({
16   - top: 150,
17   - duration: 30
18   - });
19 42 }
20 43 }
21 44 </script>
... ...
src/components/base/notification/index.js
... ... @@ -10,15 +10,18 @@ Notification.newInstance = properties =&gt; {
10 10 props += ' :' + camelcaseToHyphen(prop) + '=' + prop;
11 11 });
12 12  
13   - const div = document.createElement('div');
14   - div.innerHTML = `<notification${props}></notification>`;
15   - document.body.appendChild(div);
16   -
17   - const notification = new Vue({
18   - el: div,
  13 + const Instance = new Vue({
19 14 data: _props,
20   - components: { Notification }
21   - }).$children[0];
  15 + render (h) {
  16 + return h(Notification, {
  17 + props: _props
  18 + })
  19 + }
  20 + });
  21 +
  22 + const component = Instance.$mount();
  23 + document.body.appendChild(component.$el);
  24 + const notification = Instance.$children[0];
22 25  
23 26 return {
24 27 notice (noticeProps) {
... ...