codecamp

CRMEB v4 前端引用组件

引入外部模块

默认已经内置了许多模块,在一些业务中,可能还需要引入第三方的模块,以vue-grid-layout为例。

安装依赖

在终端安装vue-grid-layout

$ npm install vue-grid-layout --save

使用

全局注册

src/main.js中注册并使用组件:

// src/main.js
// 导入组件
import { GridLayout, GridItem } from 'vue-grid-layout';
// 使用组件
Vue.component('i-grid-layout', GridLayout);
Vue.component('i-grid-item', GridItem);

全局注册后,任何地方都可以使用<i-grid-layout><i-grid-item>两个组件了。

局部注册

只在需要的页面或组件中注册:

<template>
  <i-grid-layout>
    <i-grid-item />
  </i-grid-layout>
</template>
<script>
import { GridLayout, GridItem } from 'vue-grid-layout';
export default {
  components: { GridLayout, GridItem },
  data () {
    return {
    }
  }
}
</script>

自己封装组件

如果是自己封装的组件,可以放置在src/components目录内,使用方法不变。

CRMEB v4 前端添加页面
CRMEB v4 前端构建和发布
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

CRMEB V4操作说明

CRMEB V4用户管理

CRMEB v4 支付说明

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }