初始化 Emberjs 项目

栏目: 编程语言 · 发布时间: 7年前

内容简介:其中在命令行中运行之后,打开

Ember Guide

1. 初始化一个新的项目

1.1 生成项目

ember new ember-guide --no-welcome --yarn

其中 --no-welcome 用于跳过ember-cli 初始化项目时自带的 welcome 组件。 --yarn 是在初始化完成之后,就进行依赖的安装。

在命令行中运行

ember s

之后,打开 localhost:4200 之,就能看到

Welcome to Ember

这就说明Ember的项目已经成功启动。

1.2 配置为Pods目录

目前项采取的是Pods目录,具体的设置为:

//  ./.ember-cli
{
    "disableAnalutics": true,
    "usePods": true
}
//  ./config/environment.js
module.exports = function(environment) {
    let ENV = {
        modulePrefix: 'ember-guide',
        podModulePrefix: 'ember-guide/modules',
        environment,
        rootURL: '/',
        locationType: 'auto',
    }
}

其中 ember-demo/modules 将在 app 文件夹下生成 modules 文件夹,此为 pod 目录中的主文件夹,可自定义名称。

此后使用 ember g 命令即会在 app/modules 文件夹下生成相应的 文件。

app/routes
app/controllers
app/components
app/models
app/templates

删除 app/templates 文件夹之后,别忘记重新生成 application 路由。

1.3 安装必要的插件

  1. 使用 bootstrap v4 :
ember install ember-bootstrap

利用 ember-bootstrapblueprient 使用 CSS 预处理器 sass :

ember generate ember-bootstrap --preprocessor=sass

2.使用 css module :

ember install ember-css-modules ember-css-modules-sass

重启应用,即可。

// 自动引入依赖包
yarn add ember-auto-import --dev 

// mock数据
yarn add ember-cli-mirage --dev

// truth helper
yarn add ember-truth-helper --dev

Written by Frank Wang .


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Coming of Age in Second Life

Coming of Age in Second Life

Tom Boellstorff / Princeton University Press / 2008-04-21 / USD 29.95

The gap between the virtual and the physical, and its effect on the ideas of personhood and relationships, is the most interesting aspect of Boellstorff's analysis... Boellstorff's portrayal of a virt......一起来看看 《Coming of Age in Second Life》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

html转js在线工具
html转js在线工具

html转js在线工具