好吧,我看过这个网站并找到了几个不同的答案,其中没有一个对我有用.基本上有一个js文件,其中包含许多函数以及应用程序的主要代码.我想将我的所有函数移动到另一个js文件,以便我可以稍微清理一下我的代码.我对js相当新,但我知道在python中它就像从(路径)说"import(module)as(nickname)"一样简单
不管怎样,让我说我的functions.js模块中有一个名为show message的函数.
export function show_message(){
alert("Hello");
}
Run Code Online (Sandbox Code Playgroud)
然后我在我的main.js文件的顶部
import { show_message } from './functions.js'
//I have also tried to import like this:
import * as func from './functions.js'
//And then I call it
show_message();
//I have also tried
func.show_message();
Run Code Online (Sandbox Code Playgroud)
我知道这很简单,但正如我在任何地方所说的那样,我看到了不同的答案,其中没有一个适合我.我正在使用Firefox btw.我也在控制台中收到错误,说我的导入声明需要在我的模块的顶部,我通过在HTML链接中指定类型来修复它(脚本src ="/ static/main.js"type ="模块")错误消失但现在说"同源策略不允许在文件(路径)读取远程资源(原因:cors请求不是HTTP)."
另一个错误是"本文档中不允许使用模块源URI".
这让我觉得我的导入语法可能正确,错误在我的HTML代码中?
任何帮助表示赞赏.
我最近开始使用MASM语言学习x86 Assembly。
我正在使用Isreal Gbati编写的Udemy课程“从头开始使用x86汇编语言”进行学习。
下面的代码来自该课程中的一课(不是我想出的代码)。此函数在C程序中由main调用。这里是:
#include <stdio.h>
#include <stdlib.h>
extern int AdderASM(int a, int b, int c);
int main(void)
{
int a = 17;
int b = 11;
int c = 14;
int sum = AdderASM(a, b, c);
printf("A = %d\n", a);
printf("B = %d\n", b);
printf("C = %d\n", c);
printf("SUM FROM ASSEMBLY FUNCTION = %d\n", sum);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是程序集:
.386
.model flat, c
.code
AdderASM PROC
PUSH EBP
MOV EBP, ESP
MOV EAX, [EBP+8]
MOV ECX, [EBP+12]
MOV …
Run Code Online (Sandbox Code Playgroud)