我正在尝试将我的CFML代码转换为CFScript,但我收到了CFHtmlToPdf的错误.
CFML:
<cfoutput>
<cfhtmltopdf orientation="portrait" pagetype="A4" margintop="1" marginbottom="1" name=pdfFile>
#arguments.data.HTMLData#
</cfhtmltopdf>
<cfmail type=HTML to="#arguments.data.Email#" from="support@mydomain.com" subject="Form Test" server="localhost">
TEST
<cfmailparam file="#arguments.data.ReportName#.pdf" type="application/pdf" content="#pdfFile#"/>
</cfmail>
</cfoutput>
Run Code Online (Sandbox Code Playgroud)
我的cfscript代码:
cfhtmltopdf(source=arguments.data.HTMLData, destination=pdfPath);
mailerService = new mail();
mailerService.setTo("arguments.data.Email");
mailerService.setFrom("support@mydomain.com");
mailerService.setSubject("Form Test");
mailerService.setType("html");
mailerService.addParam(file="Test.pdf",type="application/pdf",content=pdfPath);
mailerService.send(body="Test");
Run Code Online (Sandbox Code Playgroud)
我收到错误:
src不是正确的URL,或者绝对路径指定的文件不存在.
行中出现错误:
cfhtmltopdf(source=arguments.data.HTMLData, destination=pdfPath);
Run Code Online (Sandbox Code Playgroud)
我在cfscript中错误地使用CFHtmlToPdf吗?
我正在尝试添加react-hook-form到我的reactstrap表单和输入中,但看起来包之间存在冲突。
import React, { useState, useEffect } from 'react';
import { useForm } from "react-hook-form";
import {
Button,
Form,
Label,
Input
} from 'reactstrap';
import { FormControlLabel, Checkbox, FormGroup } from '@material-ui/core';
...
const { register, handleSubmit, errors } = useForm();
...
const updDetails = (data) => {
console.log(data);
}
return (
<Form onSubmit={handleSubmit(updDetails)}>
<FormGroup className="mr-10 mb-10">
<Label for="compName" className="mr-sm-10">Company Name</Label>
<Input type="text" name="compName" id="compName" placeholder="Company Name"
ref={register({ required: true })} aria-invalid={errors.name ? "true" : "false"} …Run Code Online (Sandbox Code Playgroud) 我开始使用它react-hook-form来验证我的输入,但即使我在输入字段中键入/输入某些内容,要求规则也始终会触发。
import React, { useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { Button, Form, Label, Input } from "reactstrap";
const setErrorStyle = (name) => {
return {
borderColor: name ? "red" : "",
boxShadow: name ? "0 0 1.5px 1px red" : ""
};
};
const App = () => {
const [comment, setComment] = useState("");
const {
handleSubmit,
control,
formState: { errors }
} = useForm();
const submitForm = (data) => { …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 React Native 中创建一个方法,将我的输入格式化为美元格式。
onChangeNumberFormat = (text, input) => {
const obj = { ...this.state.data };
const value = text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,')
obj[input] = value;
this.setState({
data: obj
});
};
Run Code Online (Sandbox Code Playgroud)
我的输入(我使用的是 Native Base):
<Input
value={Amount}
onChangeText={(text) => this.onChangeNumberFormat(text, 'RentalAmount')}
style={styles.valueText}
/>
Run Code Online (Sandbox Code Playgroud)
当我输入 5000.00 时,它的格式为 5,000.00,这是正确的。但是,如果我删除最后 3 个 0 零,它会变成 5,00 而不是 500。我该如何解决?另外,有没有办法始终将“$”放在前面并只接受输入中的数字?
谢谢
有没有办法在cfscript中使用?我在网上找不到一个简单的例子。我有一个使用cfscript构建的.cfc文件,并且正在尝试使用cfxml。
我有一个XMLContent变量,并且尝试了下面的代码。
cfxml variable="myXML" {
WriteOutPut(#XMLContent#);
}
Run Code Online (Sandbox Code Playgroud)
它正在返回:function keyword is missing in FUNCTION declaration.在我的cfxml声明中。
我正在尝试更改 的头部mui-datatables,但它无法正常工作。
import MUIDataTable from "mui-datatables";
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
...
// here I set the them
const getMuiTheme = () => createMuiTheme({
overrides: {
MuiTableHead: {
root: {
backgroundColor: "#c1e1ec"
}
}
}
});
...
// rendering
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
title={"Existing Users"}
data={users}
columns={columns}
options={options}
/>
</MuiThemeProvider>
Run Code Online (Sandbox Code Playgroud)
它不会改变头部的颜色。一直露出白头。但是,如果我使用 Firefox 检查该元素,我可以看到 head 元素的以下样式
.MuiTableHead-root {
display: table-header-group;
background-color: #c1e1ec;
}
Run Code Online (Sandbox Code Playgroud) 我在使用 React useMemo 和 onClick 调用函数时遇到问题。它说我需要添加该函数作为 useMemo 依赖项,但是当我添加它时,该函数会使 useMemo Hook 在每次渲染时发生变化。
const test = useMemo(() => {
return myData.map((obj, index) => {
return (
<div key={index}>
<button type="button" onClick={() => myFunc(index)}>Test</button>
</div>
)
});
}, [myData]);
Run Code Online (Sandbox Code Playgroud)
它返回警告:React Hook useMemo has a missing dependency: 'myFunc'. Either include it or remove the dependency array
我尝试将其包含在依赖项中[myData, myFunc]。然后,它返回:The 'myFunc' function makes the dependencies of useMemo Hook (at line 105) change on every render. Move it inside the useMemo callback. Alternatively, …
我一直在使用 NodeJS 异步,但我试图了解 JavaScript 中的基本承诺,但我遇到了问题。
我创建了下面的代码进行测试。
function first() {
// Simulate a code delay
return new Promise(function(resolve) {
setTimeout(function() {
console.log(1);
}, 500);
});
}
function second() {
console.log(2);
}
first().then(second());Run Code Online (Sandbox Code Playgroud)
它应该首先打印“1”,但它首先在控制台中打印“2”。为什么会发生?
谢谢
reactjs ×4
cfml ×2
coldfusion ×2
javascript ×1
react-native ×1
reactstrap ×1
regex ×1
xml-parsing ×1