当我尝试导入 HTML 文件时,Parcel 2 抛出错误 package.json运行命令:./src/index.html./src/main.js./src/other.html错误:环境

问题描述

我正在测试新的 Parcel 2,所以我做了一个简单的项目来测试它,但是当我尝试将 HTML 文件导入到 Javascript 中时遇到了一个不方便的问题,请参阅下面我在做什么。


package.json

ctypes

运行命令:

    #If there is an optimal solution,output the optimal solution and the extreme value of the objective function
    X=[0]*self.X_count
    count=0
    for i in self.B:
            X[i]=self.bound[count][self.X_count]
            count+=1
    Z=0
    for i in range(self.X_count):
        Z+=self.z[i]*X[i]
    if self.special:
        print("No feasible solution")
    elif self.flag==1:
        print("There is a unique optimal solution",X,format(Z,'.2f'))
    elif self.flag==0:
        print("No solution")

#Check(),check whether it is the optimal solution
def Check(self):
    self.flag=1
    for i in range(self.b_count):
        if self.bound[i][self.X_count]<0:       #If there are constraints on the right end of the constant is negative,continue to iterate
            self.flag=0
            break

#pivot(),basis transformation (rotation)
def pivot(self):
    [i,j,main]=self.FindMain()  #Simplicity method: Find the main element
    self.B[i]=j                 #The swap-out variable in the base variable is replaced with the swap-in variable
    for x in range(self.X_count+1): #Transform the line of the base variable
        self.bound[i][x]=self.bound[i][x]/main
    for k in range(self.b_count):   #Transform other lines
        if k!=i:
            times=self.bound[k][j]  #multiple
            for t in range(self.X_count+1):
                temp=self.bound[i][t]*times
                self.bound[k][t]=self.bound[k][t]-temp

def FindMain(self):                 #Find the main element according to the θ rule and determine the swap-in and swap-out variables
    matbound=np.mat(self.bound)
    if np.min(matbound[:,:-1])>=0:
        self.special=True
    bi=[]
    for i in range(self.b_count):
        bi.append(self.bound[i][self.X_count])
    IoUt=bi.index(min(bi))          #OK to swap out variables
    Theta=[]                        #θ
    for j in range(self.X_count):
        if self.bound[IoUt][j]>=0 or self.C[j]==0:      #The dividend is not 0,the divisor must be less than 0
            theta=float('inf')      #Give a positive infinite number for easy elimination
        else:
            theta=self.C[j]/self.bound[IoUt][j]
        Theta.append(theta)
    jin=Theta.index(min(Theta))      #OK to swap in variables
    main=self.bound[IoUt][jin]
    return [IoUt,jin,main]

./src/index.html

{
  "name": "client-example","version": "0.0.1","description": "","scripts": {
    "build": "parcel build ./src/index.html --dist-dir ./dist","dev": "parcel ./src/index.html --dist-dir ./dist-dev","test": "echo \"Error: no test specified\" && exit 1"
  },"author": "Varela","license": "Apache-2.0","devDependencies": {
    "@parcel/transformer-inline-string": "^2.0.0-beta.2","@parcel/transformer-sass": "^2.0.0-beta.2","parcel": "^2.0.0-beta.2"
  }
}

./src/main.js

npm run dev

./src/other.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
</head>
<body>
    <script src="./main.js"></script>
</body>
</html>

错误

import otherHTML from "./other.html"

环境

软件 版本
包裹 2.0.0-beta.2
节点 v14.17.0
npm/纱线 7.18.1
操作系统 Fedora 34(三十四)x86_64

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)