小编mat*_*ace的帖子

如何让Babel 6编译为ES5 javascript?

我已经安装了最新版本的babel.目前6.4.0.我创建了一个名为myclass.js的文件,其中包含以下代码.

class MyClass {
    constructor(name) {
        console.log("I am a MyClass object .. ", name);
    }
}

var myclass = new MyClass('1234');
Run Code Online (Sandbox Code Playgroud)

创建我的类后,我在命令行中执行以下操作.

$> babel ./src/myclass.js --out-file ./out/app.js
Run Code Online (Sandbox Code Playgroud)

我希望我的app.js文件有es5编译的javascript,但它具有与myclass.js文件相同的精确代码.我错过了什么可能导致这种情况?

ecmascript-6 babeljs

57
推荐指数
2
解决办法
4万
查看次数

使用CSS3触摸事件悬停效果

我正在使用CSS3悬停和过渡来显示和隐藏图像.在移动设备上,我想对触摸事件使用相同的过渡.

基本上,第一次触摸将执行悬停效果或翻转,并且触摸将执行滚动.

我想远离使用JavaScript来做到这一点.如果有办法用纯CSS3做这将是最好的选择.

css mobile css3 css-transitions

39
推荐指数
2
解决办法
6万
查看次数

角度测试失败,因为Component是2个模块声明的一部分

我在Angular 4中创建了一些测试.我有一个使用PrettyJsonCompont的组件,以便向用户显示格式良好的json.

当我运行测试时,我的几个组件测试失败并显示相同的消息.

失败:类型PrettyJsonComponent是2个模块的声明的一部分:PrettyJsonModule和DynamicTestModule!请考虑将PrettyJsonComponent移动到导入PrettyJsonModule和DynamicTestModule的更高模块.您还可以创建一个新的NgModule,它导出并包含PrettyJsonComponent,然后在PrettyJsonModule和DynamicTestModule中导入该NgModule.

这是我的测试的样子.

import {async, ComponentFixture, TestBed} from '@angular/core/testing';

import {ContentItemModalComponent} from './content-item-modal.component';
import {DialogService} from 'ng2-bootstrap-modal';
import {ContentItemService} from '../services/content-item.service';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {FroalaEditorModule, FroalaViewModule} from 'angular-froala-wysiwyg';
import {HttpModule} from '@angular/http';
import {MainModel} from '../models/main-model';
import {PrettyJsonComponent, PrettyJsonModule} from 'angular2-prettyjson';

describe('ContentItemModalComponent', () => {
  let component: ContentItemModalComponent;
  let fixture: ComponentFixture<ContentItemModalComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        ReactiveFormsModule,
        FormsModule,
        FroalaEditorModule.forRoot(),
        FroalaViewModule.forRoot(),
        HttpModule,
        PrettyJsonModule
      ],
      declarations: [ContentItemModalComponent, PrettyJsonComponent],
      providers: [
        DialogService,
        ContentItemService,
        MainModel
      ],
    })
      .compileComponents(); …
Run Code Online (Sandbox Code Playgroud)

angular

13
推荐指数
1
解决办法
5043
查看次数

如何使用swift在iOS 8中插入图像内联UILabel

我按照以下文章介绍了如何使用NSTextAttachment添加与UILabel内联的图像.我尽我所能,并在Swift中编写了我的版本.

我正在创建一个聊天应用程序,我正在插入啤酒图标的字段不会渲染图像或似乎没有内嵌渲染图像.我没有收到任何错误,所以我假设我在代码中遗漏了一些小细节.

var beerName:String!

        if(sender == bn_beer1)
        {
            beerName = "beer1.png"
        }

        if(sender == bn_beer2)
        {
            beerName = "beer2.png"
        }

        if(sender == bn_beer3)
        {
            beerName = "beer3"
        }



        var attachment:NSTextAttachment = NSTextAttachment()
        attachment.image = UIImage(named: beerName)


        var attachmentString:NSAttributedString = NSAttributedString(attachment: attachment)
        var myString:NSMutableAttributedString = NSMutableAttributedString(string: inputField.text)
        myString.appendAttributedString(attachmentString)



        inputField.attributedText = myString;
Run Code Online (Sandbox Code Playgroud)

nstextattachment swift ios8

11
推荐指数
3
解决办法
2万
查看次数

为什么在为 iOS 编译 assimp 时出现“当前目标不支持线程本地存储”错误

我目前正在尝试在虚幻引擎项目中使用 assimp 库http://assimp.org 。我能够编译该库的 Windows 和 Mac 版本,以便我可以将它们链接到我的项目。

我现在面临的问题是编译iOS版本。正如我在项目中提交的 github 问题中所述,在编译时我不断遇到以下问题。https://github.com/assimp/assimp/issues/3690

我不认为这是它本身的问题assimp。我相信这是 macOS 及其编译 C++ 代码方式的问题。

这是我提交的 github 问题。我相信它包含解释我遇到的错误所需的所有信息。我只是不确定此时如何解决它。

在 macOS 上,我已从 cmake --build cd 构建了 assimp 到 port/iOS/ ./build.sh 中,但出现以下错误。

[ 92%] Building CXX object code/CMakeFiles/assimp.dir/AssetLib/Assjson/json_exporter.cpp.o

In file included from ~/assimp/code/Pbrt/PbrtExporter.cpp:87:
~/assimp/code/Pbrt/stb_image.h:931:1: error: thread-local storage is not supported for the
      current target
STBI_THREAD_LOCAL
^
~/assimp/code/Pbrt/stb_image.h:592:39: note: expanded from macro 'STBI_THREAD_LOCAL'
      #define STBI_THREAD_LOCAL       thread_local
                                      ^
~/assimp/code/Pbrt/stb_image.h:1070:8: error: thread-local storage is not supported for the
      current …
Run Code Online (Sandbox Code Playgroud)

c++ ios assimp

10
推荐指数
0
解决办法
5510
查看次数

由于activeadmin邮件程序,heroku上的迁移失败

我正在将应用程序部署到heroku,应用程序在rails 3.2上,我安装了活动的admin gem.

当我运行rake db:migrate时,由于以下错误而失败

    ==  DeviseCreateAdminUsers: migrating =========================================
-- create_table(:admin_users)
   -> 0.0823s

Sent mail to admin@example.com (3228ms)
rake aborted!
An error has occurred, this and all later migrations canceled:

Connection refused - connect(2)
Run Code Online (Sandbox Code Playgroud)

想知道我需要做些什么来解决这个问题.似乎Devise gem或ActiveAdmin需要在迁移过程中发送邮件,因为如果失败则不能发送邮件.

heroku ruby-on-rails-3 activeadmin

6
推荐指数
1
解决办法
664
查看次数

如何在没有GeoFire的情况下查询Firebase地理位置,以便根据两点之间的距离返回结果?

Firebase刚刚将他们的sdk更新为3.x,当前版本的GeoFire 2.x无效.

我想知道的是存储地理位置值的最佳方法,以便我可以查询firebase,以便我们只返回位于用户周围的定义半径内的位置.

示例:用户定义他们希望所有距离他们不超过20英里的项目.

我想知道我是否可以存储纬度和经度中的单个值,以便我快速查询这些数据?或者这可能不是正确的方法?

ios firebase swift

6
推荐指数
1
解决办法
1765
查看次数

如何在ios模拟器中运行openfl

我安装了最新版本的Haxe 3以及最新版本的Xcode和OpenFL.

我在终端的OpenFl项目中,运行以下命令:

openfl test ios -simulator
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

/Applications/Xcode.app/Contents/Developer/usr/bin/make
Haxe device build: Release-iphoneos-v7
haxe Build.hxml -D HXCPP_ARMV7 -cpp build/Release-iphoneos-v7
cd build/Release-iphoneos-v7; export HXCPP_NO_COLOR=1; haxelib run hxcpp Build.xml -Dios -Diphone -DHXCPP_ARMV7 -DHXCPP_CPP11  -DHXCPP_CLANG -DOBJC_ARC `cat Options.txt | while read LINE; do printf " -D$LINE"; done`
Error: Could not find build target "by"
make: *** [build-haxe-armv7] Error 1
Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2
Run Code Online (Sandbox Code Playgroud)

haxe ios openfl

6
推荐指数
1
解决办法
327
查看次数

rails handle 404 with url redirect

我希望使用rails来重定向我确信在互联网上从我的旧域到新域的链接.

我想采取地址example.com/about(关于将不再存在)

并在我的application_controller中获取404,检查URL然后重定向到

newexample.com/about

最好的方法是什么?

ruby-on-rails

5
推荐指数
1
解决办法
3099
查看次数

使用Swinject时如何将参数传递给resolve方法?

我有一个测试项目,我试图将参数传递给Swinject项目中的resolve方法.

这是我的Swinject故事板扩展文件中包含的示例.

import Swinject

extension SwinjectStoryboard {

    class func setup() {

        let mainDm = MainDM()

        defaultContainer.register(MainDM.self) { _ in
            mainDm
        }

        defaultContainer.registerForStoryboard(ViewController.self) { r, c in
            c.dm = r.resolve(MainDM.self)
            c.container = defaultContainer

        }


        defaultContainer.register(GetMessageAction.self) { _, delegate in
            GetMessageAction(dm:mainDm, delegate: delegate)
        }

    }

}
Run Code Online (Sandbox Code Playgroud)

在我的ViewController中,我正在尝试执行以下操作来解决GetMessageAction

@IBOutlet weak var myText: UILabel!

    var dm:MainDM!
    var container:Container!

    override func viewDidLoad() {
        super.viewDidLoad()

        NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(3), target: self, selector: #selector(ViewController.getMessage), userInfo: nil, repeats: false)

    }

    func getMessage() {

        let action:GetMessageAction? = container.resolve(GetMessageAction.self, argument: self)! …
Run Code Online (Sandbox Code Playgroud)

dependency-injection ios swift swinject

5
推荐指数
1
解决办法
1451
查看次数