riku
10 小时以前 8e3f3890e93d097df4be744648b9ac404d20a558
1
import{getComponentLocale,useConfig}from"../config-provider/use-config";import{toCamel}from"../common/utils";import defaultLocale from"../locale/zh_CN";export default function usingConfig(o){const{componentName:e,localeTextPropName:t}=o,a=toCamel(e);return Behavior({data:{globalConfig:{}},lifetimes:{attached(){var o;null===(o=this.updateLocale)||void 0===o||o.call(this);const e=useConfig(a);this._unsubscribeLocale=e.subscribeLocale(this,()=>{var o;null===(o=this.updateLocale)||void 0===o||o.call(this)})},detached(){const o=this._unsubscribeLocale;o&&(o(),this._unsubscribeLocale=null)}},methods:{updateLocale(){const o=defaultLocale[a]||{},e=getComponentLocale(this,a,o,t);this.setData({globalConfig:e})}}})}