Comments (20)
@acmeid 已修复
babel-plugin-component
升级到 0.3.0
支持数组表达式
from mint-ui.
按需引入需要使用 babel-plugin-component
usage
e.g.
{
"presets": ["es2015", "stage-0", "stage-2"],
"plugins": ["transform-runtime", ["component", [
{ "libraryName": "mint-ui", "style": true }
]]],
"comments": false
}
from mint-ui.
我已经配置好了babel-plugin-component,引入toast、button这些是没问题的。但是popup就不行,mint-ui里面没有popup
from mint-ui.
用的最新版么 0.1.5
, 我刚才试了一下没问题
from mint-ui.
是的。vue版本:1.0.18;
引入:
import { Popup, Button } from 'mint-ui'
报错信息:
vue.common.js?e881:1853 Uncaught TypeError: Cannot read property 'name' of undefined
from mint-ui.
我用的是.vue文件模式。我不是很清楚该怎么引入和局部注册。比如这样引入的时候:
import { Popup } from 'mint-ui'
Popup是undefined
from mint-ui.
如果配置了 babel-plugin-component 才能使用按需加载。如果没有配置 import { Popup } from 'mint-ui'
时还是引入的主文件,目前主文件里忘记配置 Popup 了,会导致 undefined,但是如果使用了那个插件不应该有这问题。
from mint-ui.
升级了 0.1.6
你再试试
from mint-ui.
Popup可以了,但是(最怕但是了哈哈哈),Picker仍然不行。mint-ui也就是index文件里面有Picker这个对象,引入的时候,不是undefined。却仍然报错,估计这个组件才是真正的没有配置name
Array-syntax assets must provide a "name" or "id" field.
and
Unknown custom element: <mt-picker> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
我目前使用这样临时解决:
import picker from 'mint-ui/lib/picker' require('mint-ui/lib/picker/style.css')
from mint-ui.
现在是 0.1.7
再试试
from mint-ui.
哦 我明白了,你配置的 babel 插件没生效啊。index.js 文件里引入的 picker 没有设置上名字,一会我改一下。但是如果插件生效应该是可行的才对。
from mint-ui.
现在 0.1.9
你检查下你的配置项,babel-plugin-component 并没有生效,下面两种方式应该是等价的
import picker from 'mint-ui/lib/picker'
import 'mint-ui/lib/picker/style.css'
import { picker } from 'mint-ui'
但是如果不用那个插件 import { picker } from 'mint-ui'
是 index.js 里的(也就是引入了整个文件),那里面的我之前是忘记加名字了。
from mint-ui.
真是奇怪了,我安装最新的是0.1.8啊,没有0.1.9。而且我也把babel-plugin-component升级到0.2.0.
现在是报 not defined
import { Popup } from 'mint-ui'
components: [ Popup ],
Uncaught ReferenceError: Popup is not defined
from mint-ui.
components 接受的是对象而不是数组吧?(前面说错是 0.1.8)
components: { Popup }
from mint-ui.
果然是。我之前一直用的都是[],现在换成{}就可以了。可能是mint-ui组件使用的注册方式不一样吧。谢谢
from mint-ui.
有可以参考的么,我看了文档貌似 components 只接受对象格式一种吧 😂
from mint-ui.
不是,可以使用数组局部注册,components: [ Popup ]
可能是vue-loader起到的作用,这个我没研究过。
问题又来了😂
我现在只能这样注册:
components: { 'mt-button': Button, 'mt-popup': Popup, 'mt-picker': Picker },
下面都不行:
components: { Button, Popup, Picker },
components: [ Button, Popup, Picker ],
报未定义错误,我也不知道这算不算是个bug了
from mint-ui.
是的,这是 ES6 的语法
{ Popup }
会被翻译成 { Popup: Popup }
所以只能通过 <popup></popup>
使用。
from mint-ui.
嗯嗯,这个确实是。那这点应该不是bug了。
看来我得看一下为什么不能使用数组注册。我本地写的组件都是用数组注册的。
from mint-ui.
是 bug
居然可以接受数组,babel 插件的问题,我在解决。
from mint-ui.
Related Issues (20)
- [Feature Request] 建议所有样式编写使用class类名以支持小程序识别
- 这么好的项目,居然不维护了 HOT 7
- datepicker组件如何防止事件冒泡呢? HOT 1
- 使用 MessageBox.prompt 属性加上inputValue 后 报错 [Vue warn]: Error in callback for watcher "inputValue": "TypeError: Cannot read property 'classList' of undefined" HOT 1
- picker-selected
- timepicker文档跟源码demo的调用方式竟然不一样。文档里直接唤不起来
- 在?为什么两年多不更新?饿了么前端是解散了吗?考虑下这么多star的感受啊! HOT 4
- [Bug Report] mintui 的 checkList 组件 设置max,达到值后虽然置灰,但是页面仍然可以选择bug?
- mint-ui的文档怎么打不开了呢,有大佬知道吗,麻烦告诉下最新的api文档地址,谢谢 HOT 3
- range组件无法拖动 HOT 1
- ios datetime-picker年份未显示出来
- 别关闭,快看 HOT 6
- 求大佬帮忙 HOT 1
- Navbar组件修改样式不生效
- 项目无法运行
- 什么时候支持Vue3??? HOT 4
- 主题色修改
- mt-search 使用问题
- picker可以支持自定义弹出吗 就是点击按钮弹出picker HOT 3
- fix: Checklist组件 在ios手机上面 出现点击无效问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mint-ui.