小编Jal*_*lil的帖子

找不到模块“babel-core”但安装了@babel/core

运行jest测试后,其中之一出现此错误。

Cannot find module 'babel-core'

      at Object.<anonymous> (node_modules/vue-jest/lib/compilers/babel-compiler.js:1:15)
Run Code Online (Sandbox Code Playgroud)

这很简单。未安装 babel-core。但是安装了更新版本的 babel-core (@babel/core)!

在这里我添加我的 package.json devDependencies

"devDependencies": {
    "@babel/core": "^7.4.5",
    "@babel/preset-env": "^7.4.5",
    "@babel/runtime": "^7.4.4",
    "@vue/cli-plugin-babel": "^3.7.0",
    "@vue/cli-plugin-eslint": "^3.7.0",
    "@vue/cli-plugin-pwa": "^3.7.0",
    "@vue/cli-service": "^3.7.0",
    "@vue/test-utils": "^1.0.0-beta.29",
    "axios-mock-adapter": "^1.16.0",
    "babel-eslint": "^10.0.1",
    "babel-loader": "^8.0.6",
    "babel-preset-env": "^1.7.0",
    "bootstrap": "^4.3.1",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0",
    "gulp-babel": "^8.0.0",
    "jest": "^24.8.0",
    "jest-serializer-vue": "^2.0.2",
    "jest-transform-stub": "^2.0.0",
    "jest-watch-typeahead": "^0.3.1",
    "json-loader": "^0.5.7",
    "less-loader": "^4.1.0",
    "postcss-flexbugs-fixes": "^4.1.0",
    "postcss-loader": "^3.0.0",
    "raw-loader": "^2.0.0",
    "sw-precache-webpack-plugin": "^0.11.5",
    "vue-jest": "^3.0.4",
    "vue-loader": "^15.7.0",
    "vue-template-compiler": "^2.5.21",
    "webpack": "^4.32.0",
    "webpack-cli": …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js jestjs babeljs

12
推荐指数
1
解决办法
5023
查看次数

Import Unexpected identifier + SyntaxError: Unexpected string

I'm having a problem when running jest test. I'm getting an import unexpected identifier

I have already tried by cleaning npm cache and installing npm babel jest, polyfill, preset-es2015. I've also read this trying some different configs here and there.

This is my babel.config.js

module.exports = {
  presets: [
    '@vue/app'
  ],
  env: {
    test: {
      plugins: [
        "transform-strict-mode",
        "transform-es2015-modules-commonjs",
        "transform-es2015-spread",
        "transform-es2015-destructuring",
        "transform-es2015-parameters"
      ]
    }
  }
}

Run Code Online (Sandbox Code Playgroud)

and my jest config in package.json

"jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "vue"
    ], …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js jestjs babeljs

10
推荐指数
1
解决办法
2005
查看次数

iOS13后分段控制器背景灰色

我目前在使用 iOS 13 分段控制器时遇到问题。我有这个方法来改变我的分段控制器的外观,它在 iOS 13 出来之前一直很好用。现在我的 segmentedController 始终具有灰色背景,即使我将背景颜色设置为白色、黑色或其他颜色。

我能做什么?

- (void)modifySegmentedControl{
    if (@available(iOS 13.0, *)) {
        [_segmentedControl setBackgroundColor:UIColor.clearColor];
        [_segmentedControl setSelectedSegmentTintColor:UIColor.clearColor];
    } else {
         //I had this for <iOS13, it works great
        [_segmentedControl setBackgroundColor:UIColor.clearColor];
        [_segmentedControl setTintColor:UIColor.clearColor];
    }

    [_segmentedControl setTitleTextAttributes:
       [NSDictionary dictionaryWithObjectsAndKeys:
        [UIColor colorWithRed:0.25 green:0.25 blue:0.25 alpha:0.6], NSForegroundColorAttributeName,
        [UIFont fontWithName:@"Poppins-Medium" size:15.0], NSFontAttributeName,
       nil]
    forState: UIControlStateNormal];

    [_segmentedControl setTitleTextAttributes:
       [NSDictionary dictionaryWithObjectsAndKeys:
        [UIColor colorWithRed:0.25 green:0.25 blue:0.25 alpha:1.0], NSForegroundColorAttributeName,
        [UIFont fontWithName:@"Poppins-Medium" size:15.0], NSFontAttributeName,
       nil]
    forState: UIControlStateSelected];

    self->greenBar = [[UIView alloc] init];
//This needs to be …
Run Code Online (Sandbox Code Playgroud)

objective-c uisegmentedcontrol ios

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