我正在使用webpack + babel.我有三个模块看起来像这样:
// A.js
// some other imports here
console.log('A');
export default 'some-const';
// B.js
import someConst from './A';
console.log('B', someConst);
export default 'something-else';
// main.js
import someConst from './A';
import somethingElse from './B';
console.log('main', someConst);
Run Code Online (Sandbox Code Playgroud)
何时main.js执行,我看到以下内容:
B undefined
A
main some-const
Run Code Online (Sandbox Code Playgroud)
如果我交换进口main.js,B成为第一个,我得到:
A
B some-const
main some-const
Run Code Online (Sandbox Code Playgroud)
为什么在第一个版本中B.js获取undefined而不是模块?怎么了?
我在WPF绘图性能方面遇到问题.有许多小的EllipseGeometry对象(例如1024个椭圆),它们被添加到具有不同前景画笔的三个单独的GeometryGroup中.之后,我在简单的图像控件上渲染它.码:
DrawingGroup tmpDrawing = new DrawingGroup();
GeometryGroup onGroup = new GeometryGroup();
GeometryGroup offGroup = new GeometryGroup();
GeometryGroup disabledGroup = new GeometryGroup();
for (int x = 0; x < DisplayWidth; ++x)
{
for (int y = 0; y < DisplayHeight; ++y)
{
if (States[x, y] == true) onGroup.Children.Add(new EllipseGeometry(new Rect((double)x * EDGE, (double)y * EDGE, EDGE, EDGE)));
else if (States[x, y] == false) offGroup.Children.Add(new EllipseGeometry(new Rect((double)x * EDGE, (double)y * EDGE, EDGE, EDGE)));
else disabledGroup.Children.Add(new EllipseGeometry(new Rect((double)x * EDGE, (double)y * …Run Code Online (Sandbox Code Playgroud) 我的容器有以下Dockerfile:
FROM centos:centos7
# Install software
RUN yum -y update && yum clean all
RUN yum install -y tar gzip wget && yum clean all
# Install io.js
RUN mkdir /root/iojs
RUN wget https://iojs.org/dist/v1.1.0/iojs-v1.1.0-linux-x64.tar.gz
RUN tar -zxvf iojs-v1.1.0-linux-x64.tar.gz -C /root/iojs
RUN rm -f iojs-v1.1.0-linux-x64.tar.gz
# add io.js to path
RUN echo "PATH=$PATH:/root/iojs/iojs-v1.1.0-linux-x64/bin" >> /root/.bashrc
# go to /src
WORKDIR /src
CMD /bin/bash
Run Code Online (Sandbox Code Playgroud)
我构建这个容器并启动图像docker run -i -t -p 8080:8080 -v /srv/source:/usr/src/app -w /usr/src/app --rm iojs-dev bash.Docker将端口8080绑定到主机端口8080,以便我可以从我的客户端访问iojs-application.一切正常.
现在我想用docker-compose启动我的容器,使用以下docker-compose.yml
webfrontend:
image: …Run Code Online (Sandbox Code Playgroud) 我有一个网站运行Joomla!(它不是我的,所以我不知道它是如何构建的).
我遇到了一个非常奇怪的问题:当我使用它phpMyAdmin并且我想编辑表中的条目时 - 我收到一个错误403.如果我复制按钮的链接位置Edit并将其放在一个新选项卡中 - 我会得到相同的.通过反复试验我发现,如果我用其他任何东西(或者,例如)替换where_clauseGET参数的值部分- 一切都按预期工作.%60id%60%60foo%60id
你有什么想法,什么可能导致这种奇怪的行为?为什么id?为什么这么特别?
PS %60代表`
我有以下渲染器:
import SerialPort from "serialport";
new SerialPort("/dev/tty-usbserial1", { baudRate: 57600 });
Run Code Online (Sandbox Code Playgroud)
它由 Webpack 构建,具有以下配置(为简洁起见进行了修剪):
const config = {
entry: { renderer: ["./src/renderer"] }
output: {
path: `${__dirname}/dist`,
filename: "[name].js",
},
target: "electron-renderer",
node: false, // Disables __dirname mocking and such
};
Run Code Online (Sandbox Code Playgroud)
它由开发服务器以及 , 提供服务index.html,并由主进程作为网页加载(这是开发期间热模块替换所需要的)。
主进程由 Webpack 构建并发出dist。Webpack 插件还会生成以下内容dist/package.json:
{
"name": "my-app",
"main": "main.js"
}
Run Code Online (Sandbox Code Playgroud)
当我运行时electron dist,渲染器进程崩溃并出现以下错误:
Uncaught TypeError: Path must be a string. Received undefined
at assertPath (path.js:28)
at dirname (path.js:1364)
at …Run Code Online (Sandbox Code Playgroud) 我正在处理第三方基于JSON的API.通常它会用引号括起所有数字,但有时它不会.我无能为力.
我正在尝试提出一个解决方案,解析数字,无论它们是否被引用.标准库提供了一个,string字段标记,它允许将数字字段映射到引用的值,但不幸的是,如果它不在引号中,则它无法处理该值.
func test(s string) {
err := json.Unmarshal([]byte(s), &struct {
F1 float64
F2 float64 `json:",string"`
}{})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("success")
}
func main() {
test(`{"f1": 1.23}`) // success
test(`{"f1": "1.23"}`) // cannot unmarshal string into Go value of type float64
test(`{"f2": 1.23}`) // invalid use of ,string struct tag, trying to unmarshal unquoted value into ...
test(`{"f2": "1.23"}`) // success
}
Run Code Online (Sandbox Code Playgroud)
有没有解决的办法?