标签: export

ES6导出一个函数的结果

我正在尝试导出 ES6 中函数的结果。该功能并不重要 - 以下示例适用于:const func = input => input

这有效:

const a = 'foo'
const b = 'bar'

export default {
  a: func(a),
  b: func(b)
}
Run Code Online (Sandbox Code Playgroud)

而这些遇到了错误SyntaxError: Unexpected token, expected ,::

export {
  a: func(a),
  b: func(b)
}
Run Code Online (Sandbox Code Playgroud)

还:

export {
  func(a) as a,
  func(b) as b
}
Run Code Online (Sandbox Code Playgroud)

你能解释一下为什么吗?这似乎不包括上述情况。

javascript export ecmascript-6

3
推荐指数
1
解决办法
3323
查看次数

`/bin/bash -c` 中的导出变量

我正在尝试在/bin/bash -c命令中导出变量。

这导致空输出:

/bin/bash -c "export FOO=foo; echo $FOO"
Run Code Online (Sandbox Code Playgroud)

这样做的正确方法是什么?

bash export quoting

3
推荐指数
1
解决办法
1041
查看次数

通过 HTTP API 导出和导入 Grafana Dashboard

我正在尝试通过其 HTTP API 导出 grafana 实例的仪表板,并使用 HTTP API 重新导入它们。

重新导入给了我以下错误(412):

{
  "message": "The dashboard belongs to plugin Prometheus.",
  "status": "plugin-dashboard"
}
{
  "message": "The dashboard has been changed by someone else",
  "status": "version-mismatch"
}
Run Code Online (Sandbox Code Playgroud)

我所做的

出口

curl --fail --insecure --user $USER:$PASSWORD --request "GET" "$TARGET/api/search" --header "Accept: application/json" | jq -r '.[].uri | select(. | startswith("db/"))' > /tmp/grafanaDashboards.txt

while read F  ; do
   FILENAME=$(basename "$F").json
   OUT=$(curl --silent --fail --insecure --user $USER:$PASSWORD --request "GET" "$TARGET/api/dashboards/$F" --header "Accept: application/json" --output "$FILENAME" --write-out '%{http_code}') …
Run Code Online (Sandbox Code Playgroud)

api import export grafana prometheus

3
推荐指数
1
解决办法
6802
查看次数

javascript 模块:Visual Studio 代码中的“export * as”

我刚刚加入了一个新项目,偶然发现了以下 JavaScript 导出语法(带别名的全局导出):

export * as actions from './Something.actions.js';
Run Code Online (Sandbox Code Playgroud)

语法似乎有效,但我以前从未见过它,它在 Visual Studio 代码中被标记为错误。它是一个有效的语法吗?有人可以解释为什么 vscode 认为这种语法不正确吗?

在此处输入图片说明

在此处输入图片说明

javascript export ecmascript-6 visual-studio-code es6-modules

3
推荐指数
1
解决办法
1837
查看次数

使用 r 包“flextable”将多个表格导出到 Word 文档

我正在尝试在同一个 word 文档中导出两个(flex)表。这是我所拥有的:

df1 <- data.frame(a = 1:3, b = 1:3)
df2 <- data.frame(c = 11:13, d = 11:13)

library(flextable)
df1_ft <- regulartable(df1)
df2_ft <- regulartable(df2)

library(officer)
word_export <- read_docx()
word_export <- body_add_flextable(word_export, df1_ft)
word_export <- body_add_flextable(word_export, df2_ft)
print(word_export, 'try.docx')
Run Code Online (Sandbox Code Playgroud)

然而,结果是包含两个表的单个表。知道如何一个接一个地添加到两个表中吗?

document export r dataframe

3
推荐指数
1
解决办法
1850
查看次数

导入“未导出”类型时出现打字稿错误,即使它已导出

我正在使用 Typescript、React 和 Redux(如果相关)。我的项目结构:

/project
  /src
    /actions
      index.ts
      actions.ts
Run Code Online (Sandbox Code Playgroud)

索引.ts

import {
    Action,
} from "./actions";

export { Action }
Run Code Online (Sandbox Code Playgroud)

我重新导出Actions,index.ts以便其他文件(不在/actions目录下)可以Actions使用import { Action } from "./actions"

动作.ts

// These are the general structures create each
// async action
type Request<T>  = { request: T }
type Response<T> = { response: T }
type Err         = { error: string }

// Alias common types for requests & responses
type EmptyRequest = Request<null> …
Run Code Online (Sandbox Code Playgroud)

import module export typescript redux

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

require 和 module.exports : TypeError: X is not a function

文件结构:

server
??? controllers
?   ??? locationsController.js
?   ??? mainController.js
?   ??? utilisateursController.js
??? models
?   ??? Locations.js
?   ??? Utilisateurs.js
|   ??? ...
??? routes.js
??? server.js

Run Code Online (Sandbox Code Playgroud)

在mainController我有一个isValid检查字符串的函数中,我把它放在那里,因为我想从utilisateursController.js和访问它locationsController.js。我将其导出如下:

mainController.js

server
??? controllers
?   ??? locationsController.js
?   ??? mainController.js
?   ??? utilisateursController.js
??? models
?   ??? Locations.js
?   ??? Utilisateurs.js
|   ??? ...
??? routes.js
??? server.js

Run Code Online (Sandbox Code Playgroud)

问题

我可以isValid从访问该函数utilisateursController.js,但是当我尝试从 执行相同操作时locationsController.js,出现以下错误:

(node:6461) UnhandledPromiseRejectionWarning: TypeError: mc.isValid is not …
Run Code Online (Sandbox Code Playgroud)

javascript export require node.js

3
推荐指数
1
解决办法
2324
查看次数

如何使用 Swift 创建 CSV 文件

在我创建的用于从Apple铅笔输入收集数据的应用程序中,我尝试将数据导出到 CSV 文件中。但到目前为止,我只设法创建了一个记录时间长度的列。我想添加另一列来记录Apple铅笔的力。

这就是我试图做的:

var patientsData:[Dictionary<String, AnyObject>] = Array()
var dct = Dictionary<String, AnyObject>()

// MARK: CSV writing
func createCSVX(from recArray:[Dictionary<String, AnyObject>]) {
var csvString = "\("Time")\n"
dct.updateValue(TestDraw.time as AnyObject, forKey: "T")
csvString = csvString.appending("\(String(describing: dct["T"]))\n")
patientsData.append(dct)
let fileManager = FileManager.default
do {
    let path = try fileManager.url(for: .documentDirectory, in: .allDomainsMask, appropriateFor: nil, create: false)
    let fileURL = path.appendingPathComponent("TrailTime.csv")
    try csvString.write(to: fileURL, atomically: true, encoding: .utf8)
} catch {
    print("error creating file")
    }

}
Run Code Online (Sandbox Code Playgroud)

我知道我可以编写另一个函数来创建另一个CSV …

csv export ios swift

3
推荐指数
1
解决办法
7746
查看次数

如何从 gl-matrix.js 正确导入?

我来自 c++ 背景,所以 javascript 不是一种熟悉的语言。但是,我想我已经弄清楚了 ES6 模块导入/导出的基础知识。我在找出流行的库 gl-matrix https://github.com/toji/gl-matrix/blob/master/dist/gl-matrix.js 中的导出语法时遇到了一些麻烦。

我可以包含gl-matrix.js在我的 html 文件中,它的代码在我的 main.js 脚本中工作正常。但是,我正在尝试在 vscode 中使用 linter (eslint) 来帮助指导我使用正确的 javascript;eslint标记类型,如vec3并mat4为红色的,因为他们是不确定的。我注意到我的其他模块也被标记为红色,直到我导入它们。

我试过这样的事情: import {vec3} from 'gl-matrix.js'; 并得到错误Uncaught SyntaxError: The requested module 'gl-matrix.js' does not provide an export named 'vec3'

我也试过import * as vl from 'gl-matrix.js';并使用 vl.vec3,但也不走运。在我看来 gl-matrix.js 没有使用 es6 模块导出,但我不确定。它肯定使用了一些导出系统。

单击 github 链接将带您到整个 gl-matrix.js 进行查看,但这里有一些它正在执行的导出类型的片段:

(function webpackUniversalModuleDefinition(root, factory) {
    if(typeof exports === 'object' && typeof module === 'object')
        module.exports = …
Run Code Online (Sandbox Code Playgroud)

javascript import export webpack

3
推荐指数
1
解决办法
2712
查看次数

Export-Csv - 拒绝访问路径“C:\export.csv”

我正在获取我需要的信息,尽管在导出信息时出现错误。

当我运行此代码时:

get-process | Export-csv -Path "C:\export.csv" -NoTypeInformation
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Export-csv : Access to the path 'C:\export.csv' is denied.
At line:1 char:14
+ get-process | Export-csv -Path "C:\export.csv" -NoTypeInformation
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)

如何导出为 CSV?

powershell export access-denied export-to-excel export-csv

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