【问题标题】:How to install Aurelia UX 0.4.0 with Aurelia CLI?如何使用 Aurelia CLI 安装 Aurelia UX 0.4.0?
【发布时间】:2018-05-13 02:35:55
【问题描述】:

我已经使用aurelia-ux 0.3.0 有一段时间了,我喜欢这个概念。自从转移到 aurelia-ux 0.4.0 并转移到 monorepo 之后,我对如何安装和使用该库有点迷茫。

谁能提供一个关于如何使用 aurelia-cli 安装 aurelia-ux 0.4.0(核心 + 1-2 个组件)的小例子?

注意:@aurelia-ux/core 包的当前 npm 文档指向 showcase application - 但是这个展示仍然运行 0.3.0。

【问题讨论】:

  • 我同意,这方面的文档完全烂透了。我也无法让 0.6.1 工作。
  • @Flores 你是对的。但是我已经能够让它工作,下面是我的回答来帮助你。希望您也可以让它工作并享受这个伟大的插件。

标签: npm aurelia


【解决方案1】:

经过一些测试和研究,我已经能够安装auralia-ux 0.4.0+

首先需要安装核心和组件

npm install @aurelia-ux/core

然后您可以单独或一起安装每个组件

npm install @aurelia-ux/button
npm install @aurelia-ux/input
npm install @aurelia-ux/...

# or

npm install @aurelia-ux/components

然后在aurelia_project/aurelia.json中你需要像这样添加依赖:

{
  "name": "@aurelia-ux/core",
  "path": "../node_modules/@aurelia-ux/core/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/button",
  "path": "../node_modules/@aurelia-ux/button/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/input",
  "path": "../node_modules/@aurelia-ux/input/dist/amd",
  "main": "index",
  "resources": [
  "**/*.{css,html}"
  ]
},

或者如果您更喜欢components 变体(警告:我没有测试过这个变体):

{
  "name": "@aurelia-ux/core",
  "path": "../node_modules/@aurelia-ux/core/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/components",
  "path": "../node_modules/@aurelia-ux/components/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
}

最后你必须在你的 main.js 中注册插件

aurelia.use
.plugin('@aurelia-ux/core')
.plugin('@aurelia-ux/button')
.plugin('@aurelia-ux/input')

或使用组件变体(未测试)

aurelia.use
.plugin('@aurelia-ux/core')
.plugin('@aurelia-ux/components')

【讨论】:

  • 谢谢!这非常有帮助。我已经尝试过组件部分,但无法使其正常工作。单个组件使用上述方法,也适用于版本 0.6.1
猜你喜欢
  • 2017-03-12
  • 2017-01-03
  • 2017-07-09
  • 1970-01-01
  • 1970-01-01
  • 2017-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多