Wordpress 材料组件Web-独立初始化
我试图只包括我需要的组件从材料组件网站,我有困难使组件初始化。我们的目标是让相同类型的所有组件在加载时进行初始化,因此我认为auto-init将是一个不错的选择Wordpress 材料组件Web-独立初始化,wordpress,webpack,material-components,material-components-web,Wordpress,Webpack,Material Components,Material Components Web,我试图只包括我需要的组件从材料组件网站,我有困难使组件初始化。我们的目标是让相同类型的所有组件在加载时进行初始化,因此我认为auto-init将是一个不错的选择 从'@material/auto init'导入mdcAutoInit'; 从'@material/textfield'导入{MDCTextField}; mdcAutoInit.register('MDCTextField',MDCTextField') 输入标签 window.mdc.autoInit(); 这似乎有效 添加'w
从'@material/auto init'导入mdcAutoInit';
从'@material/textfield'导入{MDCTextField};
mdcAutoInit.register('MDCTextField',MDCTextField')代码>
输入标签
window.mdc.autoInit();
这似乎有效
添加'window.mdcAutoInit=mdcAutoInit;'导入MDCAUTOINT后
import mdcAutoInit from '@material/auto-init';
window.mdcAutoInit = mdcAutoInit;
然后将结束标记前的初始化脚本替换为:
<script>window.mdcAutoInit();</script>
输入标签
//添加页面底部
window.mdcAutoInit();