问题描述
这是我的package.json反应。
//*** prepare text for printing
public Node getPrintableText(){
Label text = new Label();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("*********************************************" + "\n");
stringBuilder.append(" " + companyName + " \n");
stringBuilder.append("*********************************************" + "\n");
stringBuilder.append("Location: " + companyLocation + "\n");
stringBuilder.append("Contact Us: " + phoneNumber + "\n");
stringBuilder.append("TIN: " + tinNumber + "\n");
stringBuilder.append("Receipt No: " + transactionGeneratedId + "\n");
stringBuilder.append("Date: " + getCurrentTimeStamp() + "\n");
stringBuilder.append("---------------------------------------------" + "\n");
// get each product and add to printing list
for(Products product: productList){
if(product.getProduct_name().length() > 10){
// getting the first 11 characters of the product name
String name = product.getProduct_name().substring(0,9)+ "...";
stringBuilder.append(product.getQuantity_purchased() + " x " + name + " " + currencySymbol + product.getUnit_selling_price() + "\n");
}else{
stringBuilder.append(product.getQuantity_purchased() + " x " + product.getProduct_name()
+ " " + currencySymbol + product.getUnit_selling_price() + "\n");
}
stringBuilder.append("Subtotal " + currencySymbol + (Double.parseDouble(product.getQuantity_purchased()) *
Double.parseDouble(product.getUnit_selling_price())) + "\n");
stringBuilder.append("---------------------------------------------" + "\n");
}
// get overall total
stringBuilder.append("Overall Total " + currencySymbol + totalPrice + "\n");
String cashReceived = fieldCashReceived.getText().trim();
// get total amount
stringBuilder.append("Amount Paid " + currencySymbol + cashReceived + "\n");
double balance = totalPrice - Double.parseDouble(cashReceived);
stringBuilder.append("_____________________________________________" + "\n");
// get balance
stringBuilder.append("Balance " + currencySymbol + balance + "\n");
stringBuilder.append("*********************************************" + "\n");
stringBuilder.append("Thank you so much!" + "\n");
stringBuilder.append("*******************************************");
text.setText(stringBuilder.toString());
return text;
}
我在package.json文件中使用了代理,但是它对我不起作用。添加此代理后,它没有显示任何错误,但是也位于本地host3000中。
解决方法
React是常规的前端框架。这意味着最终,它将构建到一堆js文件中。因此react-scripts build
。您应该将这些文件部署到可以提供静态文件的适当HTTP服务器。进行检查以使HTTP文件服务器脱离节点https://stackoverflow.com/a/16350826/3849555。 react-scripts start
只是出于开发目的而启动Web服务器。请勿将其用作真实的Web服务器。