line-continuation 相关问题


如何分割多个不同的字符,同时保留该字符,但又不在空白处?

尝试/失败地分割两个不同的字符,但也不分割空间。 #!/usr/bin/env perl 使用严格; 我的 $line = "-abc=123 +def=456 -ghi 789"; 我的@arr = split(/([+-]\S+)/,$line); 为我的$


c# Azure.AI.OpenAI 在启动时出现错误

我正在尝试遵循 Microsoft 的操作方法(以 C# 方式): https://learn.microsoft.com/en-us/azure/ai-services/openai/use-your-data-quickstart?tabs=command-line%2Cpython&pivots=programming-lan...


为 lmer 函数 (lme4-Package) 找到 pdIdent (nlme-Package) 的等效项

我想知道是否可以使用函数 lme(nlme 包)和 pdIdent-line 将简单的混合模型分析“翻译”为 lmer(包


在 VS Code 中没有获得新创建的扩展的建议

我的代码如下: /** * 输入自动完成提供者 */ 类InputAutoCompletionProvider { // eslint-disable-next-line class-methods-use-this 提供完成项目(文档,位置...


line.new() 仅绘制当前月份,而不绘制前几个月

我尝试使用 line() 函数绘制每月前 2 天的最高和最低价格线,如下所示: //@版本=5 指标(“...的最高线和最低线


错误 org.apache.pig.tools.grunt.Grunt - 错误 1200:<line 16, column 46> 不匹配的输入“,”期望 LEFT_PAREN

grunt>joined_data=JOINfiltered_featuresBY(商店,日期),销售额BY(商店,日期); 2024-04-02 13:19:05,110 [主要] 错误 org.apache.pig.tools.grunt.Grunt - 错误 1200: grunt> joined_data = JOIN filtered_features BY (store, date), sales BY (store, date); 2024-04-02 13:19:05,110 [主要] 错误 org.apache.pig.tools.grunt.Grunt - 错误 1200: 不匹配的输入 ',' 期待 LEFT_PAREN 日志文件详细信息:/home/vboxuser/Documents/DDPC/EX9/q2/2/pig_1712044037517.log 猪堆栈跟踪 错误 1200:输入“,”不匹配,需要 LEFT_PAREN 解析失败:输入“,”不匹配,需要 LEFT_PAREN at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:244) at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:182) at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1792) at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1765) at org.apache.pig.PigServer.registerQuery(PigServer.java:708) at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:1110) at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:512) at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:230) at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:205) at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:66) at org.apache.pig.Main.run(Main.java:564) at org.apache.pig.Main.main(Main.java:175) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.hadoop.util.RunJar.run(RunJar.java:244) at org.apache.hadoop.util.RunJar.main(RunJar.java:158) ====================================================== ================================= 有括号但还是错误Left Paran 如果我提到列号,它就会起作用 grunt> join_data = JOIN Filtered_features BY ($0, $2), sales BY ($0, $1);


在 C# 中将 Task<T> 转换为 Task<object>,无需 T

我有一个充满扩展方法的静态类,其中每个方法都是异步的并返回一些值 - 像这样: 公共静态类 MyContextExtensions{ 公共静态异步任务 我有一个充满扩展方法的静态类,其中每个方法都是异步的并返回一些值 - 像这样: public static class MyContextExtensions{ public static async Task<bool> SomeFunction(this DbContext myContext){ bool output = false; //...doing stuff with myContext return output; } public static async Task<List<string>> SomeOtherFunction(this DbContext myContext){ List<string> output = new List<string>(); //...doing stuff with myContext return output; } } 我的目标是能够从另一个类中的单个方法调用这些方法中的任何一个,并将其结果作为对象返回。它看起来像这样: public class MyHub: Hub{ public async Task<object> InvokeContextExtension(string methodName){ using(var context = new DbContext()){ //This fails because of invalid cast return await (Task<object>)typeof(MyContextExtensions).GetMethod(methodName).Invoke(null, context); } } } 问题是转换失败。我的困境是我无法将任何类型参数传递给“InvokeContextExtension”方法,因为它是 SignalR 中心的一部分并且由 javascript 调用。在某种程度上,我不关心扩展方法的返回类型,因为它只会序列化为 JSON 并发送回 javascript 客户端。但是,我确实必须将 Invoke 返回的值转换为任务才能使用等待运算符。我必须为该“任务”提供一个通用参数,否则它将把返回类型视为 void。因此,这一切都归结为如何成功地将具有通用参数 T 的任务转换为具有对象通用参数的任务,其中 T 表示扩展方法的输出。 您可以分两步完成 - await使用基类执行任务,然后使用反射或dynamic收获结果: using(var context = new DbContext()) { // Get the task Task task = (Task)typeof(MyContextExtensions).GetMethod(methodName).Invoke(null, context); // Make sure it runs to completion await task.ConfigureAwait(false); // Harvest the result return (object)((dynamic)task).Result; } 这是一个完整的运行示例,它将上述通过反射调用 Task 的技术置于上下文中: class MainClass { public static void Main(string[] args) { var t1 = Task.Run(async () => Console.WriteLine(await Bar("Foo1"))); var t2 = Task.Run(async () => Console.WriteLine(await Bar("Foo2"))); Task.WaitAll(t1, t2); } public static async Task<object> Bar(string name) { Task t = (Task)typeof(MainClass).GetMethod(name).Invoke(null, new object[] { "bar" }); await t.ConfigureAwait(false); return (object)((dynamic)t).Result; } public static Task<string> Foo1(string s) { return Task.FromResult("hello"); } public static Task<bool> Foo2(string s) { return Task.FromResult(true); } } 一般来说,要将 Task<T> 转换为 Task<object>,我会简单地采用简单的连续映射: Task<T> yourTaskT; // .... Task<object> yourTaskObject = yourTaskT.ContinueWith(t => (object) t.Result); (文档链接在这里) 但是,您实际的具体需求是 通过反射调用 Task 并获取其(未知类型)结果 。 为此,您可以参考完整的dasblinkenlight的答案,它应该适合您的具体问题。 我想提供一个实现,恕我直言,这是早期答案的最佳组合: 精确的参数处理 无动态调度 通用扩展方法 给你: /// <summary> /// Casts a <see cref="Task"/> to a <see cref="Task{TResult}"/>. /// This method will throw an <see cref="InvalidCastException"/> if the specified task /// returns a value which is not identity-convertible to <typeparamref name="T"/>. /// </summary> public static async Task<T> Cast<T>(this Task task) { if (task == null) throw new ArgumentNullException(nameof(task)); if (!task.GetType().IsGenericType || task.GetType().GetGenericTypeDefinition() != typeof(Task<>)) throw new ArgumentException("An argument of type 'System.Threading.Tasks.Task`1' was expected"); await task.ConfigureAwait(false); object result = task.GetType().GetProperty(nameof(Task<object>.Result)).GetValue(task); return (T)result; } 您不能将 Task<T> 转换为 Task<object>,因为 Task<T> 不是协变的(也不是逆变的)。最简单的解决方案是使用更多反射: var task = (Task) mi.Invoke (obj, null) ; var result = task.GetType ().GetProperty ("Result").GetValue (task) ; 这很慢且效率低下,但如果不经常执行此代码则可用。顺便说一句,如果您要阻塞等待其结果,那么异步 MakeMyClass1 方法有什么用呢? 另一种可能性是为此目的编写一个扩展方法: public static Task<object> Convert<T>(this Task<T> task) { TaskCompletionSource<object> res = new TaskCompletionSource<object>(); return task.ContinueWith(t => { if (t.IsCanceled) { res.TrySetCanceled(); } else if (t.IsFaulted) { res.TrySetException(t.Exception); } else { res.TrySetResult(t.Result); } return res.Task; } , TaskContinuationOptions.ExecuteSynchronously).Unwrap(); } 它是非阻塞解决方案,将保留任务的原始状态/异常。 最有效的方法是自定义等待者: struct TaskCast<TSource, TDestination> where TSource : TDestination { readonly Task<TSource> task; public TaskCast(Task<TSource> task) { this.task = task; } public Awaiter GetAwaiter() => new Awaiter(task); public struct Awaiter : System.Runtime.CompilerServices.INotifyCompletion { System.Runtime.CompilerServices.TaskAwaiter<TSource> awaiter; public Awaiter(Task<TSource> task) { awaiter = task.GetAwaiter(); } public bool IsCompleted => awaiter.IsCompleted; public TDestination GetResult() => awaiter.GetResult(); public void OnCompleted(Action continuation) => awaiter.OnCompleted(continuation); } } 具有以下用法: Task<...> someTask = ...; await TaskCast<..., object>(someTask); 这种方法的局限性在于结果不是 Task<object> 而是一个可等待的对象。 我根据dasblinkenlight的回答做了一个小小的扩展方法: public static class TaskExtension { public async static Task<T> Cast<T>(this Task task) { if (!task.GetType().IsGenericType) throw new InvalidOperationException(); await task.ConfigureAwait(false); // Harvest the result. Ugly but works return (T)((dynamic)task).Result; } } 用途: Task<Foo> task = ... Task<object> = task.Cast<object>(); 这样您就可以将 T 中的 Task<T> 更改为您想要的任何内容。 对于最佳方法,不使用反射和动态丑陋语法,也不传递泛型类型。我将使用两种扩展方法来实现这个目标。 public static async Task<object> CastToObject<T>([NotNull] this Task<T> task) { return await task.ConfigureAwait(false); } public static async Task<TResult> Cast<TResult>([NotNull] this Task<object> task) { return (TResult) await task.ConfigureAwait(false); } 用途: Task<T1> task ... Task<T2> task2 = task.CastToObject().Cast<T2>(); 这是我的第二种方法,但不推荐: public static async Task<TResult> Cast<TSource, TResult>([NotNull] this Task<TSource> task, TResult dummy = default) { return (TResult)(object) await task.ConfigureAwait(false); } 用途: Task<T1> task ... Task<T2> task2 = task.Cast((T2) default); // Or Task<T2> task2 = task.Cast<T1, T2>(); 这是我的第三种方法,但是不推荐:(类似于第二种) public static async Task<TResult> Cast<TSource, TResult>([NotNull] this Task<TSource> task, Type<TResult> type = null) { return (TResult)(object) await task.ConfigureAwait(false); } // Dummy type class public class Type<T> { } public static class TypeExtension { public static Type<T> ToGeneric<T>(this T source) { return new Type<T>(); } } 用途: Task<T1> task ... Task<T2> task2 = task.Cast(typeof(T2).ToGeneric()); // Or Task<T2> task2 = task.Cast<T1, T2>(); 将 await 与动态/反射调用混合使用并不是一个好主意,因为 await 是一条编译器指令,它会围绕调用的方法生成大量代码,并且使用更多反射来“模拟”编译器工作并没有真正的意义,延续、包装等 因为您需要的是在运行时管理代码,然后忘记在编译时工作的 asyc await 语法糖。重写 SomeFunction 和 SomeOtherFunction 而不使用它们,并在运行时创建的您自己的任务中开始操作。您将得到相同的行为,但代码非常清晰。


更改垫输入的波纹颜色

我现在一直在努力了解如何手动更改元素的波纹颜色,但我似乎无法让它以任何方式工作。 我现在一直在努力研究如何手动更改 <mat-input> 元素的波纹颜色,但我似乎无法让它以任何方式工作。 <input matInput type="number" (keydown)="updateManualPage(1)" placeholder="Filter" formControlName="filterParam1"> 我已经尝试了CSS中我能想到的一切,.mat-form-field-underline,.mat-form-field-ripple,包括我使用::after和::before选择器从另一个SO问题/答案中无耻地撕掉的一大块类,尝试使用 ::ng-deep、!important,但似乎没有任何东西可以改变从 @import "../node_modules/@angular/material/prebuilt-themes/indigo-pink.css"; 导入的蓝色波纹的颜色 编辑:只需更好地阅读 API,所以我发现波纹后出现的边框颜色来自 <mat-form-field> 元素,该元素有一个颜色选择器。但是,该颜色选择器只能具有“primary”、“accent”和“warn”值。所以现在我想知道如何插入自定义颜色。 设法弄清楚了,原来如此 ::ng-deep .mdc-text-field--filled:not(.mdc-text-field--disabled) .mdc-line-ripple::after { border-bottom-color: *X* !important; }


VueJS [电子邮件受保护] 组件 v-model 最初不会更新父级

我有一个父子组件设置来测试 v-model。当您输入值时,子级会更新父级,但最初不会。 家长: 从“vue”导入{ref}; 导入文本输入...</desc> <question vote="0"> <p>我有一个父子组件设置来测试 v-model。当您输入值时,子级会更新父级,但最初不会。</p> <p>家长:</p> <pre><code>&lt;script setup&gt; import { ref } from &#39;vue&#39;; import TextInput from &#39;./TextInput.vue&#39;; const size = ref(1); const color = ref(&#39;red&#39;); &lt;/script&gt; &lt;template&gt; &lt;TextInput v-model:size=&#34;size&#34; v-model:color.capitalize=&#34;color&#34; /&gt; &lt;div :style=&#34;{ fontSize: size + &#39;em&#39;, color: color }&#34;&gt; &lt;!-- Question 1: this line shows &#34;red&#34; but &#34;Red&#34; is what I want initially --&gt; &lt;p&gt;{{ size }} {{ color }}&lt;/p&gt; &lt;/div&gt; &lt;/template&gt; </code></pre> <p>子:TextInput.vue</p> <pre><code>&lt;script setup&gt; import { ref } from &#39;vue&#39;; const size = defineModel(&#39;size&#39;); const [color, modifier] = defineModel(&#39;color&#39;, { set(value) { if(modifier.capitalize) { return value.charAt(0).toUpperCase() + value.slice(1); } return value; }, //only this forces color to upper case on start in the input get(value) { if(modifier.capitalize) { return value.charAt(0).toUpperCase() + value.slice(1); } return value; } }); &lt;/script&gt; &lt;template&gt; &lt;input v-model=&#34;size&#34;&gt; &lt;input v-model=&#34;color&#34;&gt; &lt;/template&gt; </code></pre> <p>问题2: 如果我在defineModel中省略“color”(“color”,{...,我会收到以下错误</p> <p>[Vue warn]:无关的非 props 属性(颜色、colorModifiers)被传递给组件但无法自动继承,因为组件渲染片段或文本根节点。</p> <pre><code>at &lt;TextInput size=1 onUpdate:size=fn color=&#34;red&#34; ... &gt; at &lt;ComponentVModel&gt; at &lt;App&gt; </code></pre> <p>如果我只保留</p> <pre><code>&lt;input v-model=&#34;color&#34;&gt; </code></pre> <p>line,为了让它不是片段,根本不更新。</p> </question> <answer tick="false" vote="0"> <p>问题 1:在调用子元素中的 v-model setter 之前,<pre><code>&lt;p&gt;</code></pre> 元素中的大写不会发生。 <strong>设置器是同步回父级的设置器</strong>。由于在输入接收到来自用户的一些文本之前不会调用设置器,因此父级中的 <pre><code>&lt;p&gt;</code></pre> 元素将显示初始值,在您的情况下为“红色”。</p> <p>问题 2:defineModel 根据第一个参数字符串“color”声明一个 prop。该道具旨在匹配父级<strong>上的</strong>v模型的参数,即<pre><code>v-model:color</code></pre>。从defineModel中删除“颜色”意味着父v模型必须从<pre><code>v-model:color</code></pre>更改为<pre><code>v-model</code></pre></p> </answer> </body></html>


ESLint:解析错误:意外的标记:

大家好我正在将我的 vue3 项目从 js 迁移到 typescript,我遇到了这个问题: 这是我在 .vue 文件中的代码 const toto = (msg: string) => { </desc> <question vote="7"> <p>大家好,我正在将我的 vue3 项目从 js 迁移到 typescript,我遇到了这个问题:</p> <p><a href="https://i.stack.imgur.com/y5tG8.png" target="_blank"><img src="https://cdn.txt58.com/i/AWkuc3RhY2suaW1ndXIuY29tL3k1dEc4LnBuZw==" alt=""/></a></p> <p>这是我在 .vue 文件中的代码</p> <pre><code>&lt;script setup lang=&#34;ts&#34;&gt; const toto = (msg: string) =&gt; { console.log(msg) } &lt;/script&gt; </code></pre> <p>这是我的 eslintrc.js</p> <pre><code>module.exports = { &#39;env&#39;: { &#39;browser&#39;: true, &#39;es2021&#39;: true }, &#39;extends&#39;: [ &#39;eslint:recommended&#39;, &#39;plugin:vue/vue3-essential&#39; ], &#39;parserOptions&#39;: { &#39;ecmaVersion&#39;: 13, &#39;sourceType&#39;: &#39;module&#39; }, &#39;plugins&#39;: [ &#39;vue&#39; ], &#39;rules&#39;: { &#39;vue/multi-word-component-names&#39;: &#39;off&#39;, &#39;vue/object-curly-spacing&#39;: [2, &#39;always&#39;], &#39;vue/html-closing-bracket-spacing&#39;: [2, { &#39;selfClosingTag&#39;: &#39;always&#39; }], &#39;vue/max-attributes-per-line&#39;: [2, { &#39;singleline&#39;: { &#39;max&#39;: 1 }, &#39;multiline&#39;: { &#39;max&#39;: 1 } }], &#39;semi&#39;: [2, &#39;never&#39;] } } </code></pre> </question> <answer tick="true" vote="10"> <p>您需要配置 eslint 以支持 typescript,因为 eslint 不支持开箱即用。 首先,您需要安装<a href="https://www.npmjs.com/package/@typescript-eslint/parser" rel="nofollow noreferrer">@typescript-eslint/parser</a>,然后安装<a href="https://www.npmjs.com/package/@typescript-eslint/eslint-plugin" rel="nofollow noreferrer">@typescript-eslint/eslint-plugin</a>。 安装完这些后,请按如下方式更新您的配置 - </p> <pre><code>module.exports = { &#39;env&#39;: { &#39;browser&#39;: true, &#39;es2021&#39;: true, node: true }, &#39;extends&#39;: [ &#39;eslint:recommended&#39;, &#39;plugin:vue/vue3-essential&#39; ], &#39;parserOptions&#39;: { &#39;ecmaVersion&#39;: 12, &#39;sourceType&#39;: &#39;module&#39;, parser: &#39;@typescript-eslint/parser&#39; }, &#39;plugins&#39;: [ &#39;vue&#39;, &#39;@typescript-eslint&#39; ], &#39;rules&#39;: { &#39;vue/multi-word-component-names&#39;: &#39;off&#39;, &#39;vue/object-curly-spacing&#39;: [2, &#39;always&#39;], &#39;vue/html-closing-bracket-spacing&#39;: [2, { &#39;selfClosingTag&#39;: &#39;always&#39; }], &#39;vue/max-attributes-per-line&#39;: [2, { &#39;singleline&#39;: { &#39;max&#39;: 1 }, &#39;multiline&#39;: { &#39;max&#39;: 1 } }], &#39;semi&#39;: [2, &#39;never&#39;] } } </code></pre> </answer> <answer tick="false" vote="1"> <p>就我而言,问题是我使用解析器选项作为数组,而不是字符串:</p> <pre><code> parserOptions: { - parser: [&#39;@typescript-eslint/parser&#39;], + parser: &#39;@typescript-eslint/parser&#39;, }, </code></pre> </answer> <answer tick="false" vote="0"> <p>如果你在项目中同时使用 JS 和 TS,此配置有帮助</p> <pre><code> overrides: [ { files: [&#39;*.vue&#39;], parser: &#39;svelte-eslint-parser&#39;, parserOptions: { parser: { // Specify a parser for each lang. ts: &#39;@typescript-eslint/parser&#39;, js: &#39;espree&#39;, typescript: &#39;@typescript-eslint/parser&#39; } } } ], </code></pre> </answer> <answer tick="false" vote="-1"> <p>我在节点 v12.22.9 上遇到了这个问题。通过升级到 v14.21.2,我不再遇到解析错误。您可以使用命令升级/安装</p> <pre><code>nvm install v14.21.2 </code></pre> </answer> </body></html>


数组内的多个数组[重复]

我正在尝试从多个数组中获取文本,我得到了第一个和第二个数组,但无法从第三个数组中获取文本。 你可以在这里看到我的代码: 我正在尝试从多数组中获取文本,我得到了第一个和第二个数组,但无法从第三个数组中获取文本。 你可以在这里看到我的代码: <div class="personTools"> <ul> <?php for ($i = 0; $i < count($toolsMenu["TOOLS_MENU"]) ; $i++){ ?> <div class="dropdown"> <li><?php echo $toolsMenu["TOOLS_MENU"][$i]; ?> <span class="fa fa-caret-down"></span></li> <div class="dropdown-content"> <?php for ($d = 0; $d < count ($toolsMenu["TOOLS_MENU"][$i]); $d++) { ?> <li><?php echo $toolsMenu["TOOLS_MENU"][$i][$d]; ?> </li> <?php } ?> </div> </div> <?php } ?> </ul> </div> 我的数组在这里: $toolsMenu = array( "TOOLS_MENU" => array( "تجربة 1" => array(1, 2, 3, 4), "تجربة 2" => array(1, 2, 3, 4), "تجربة 3" => array(1, 2, 3, 4), "تجربة 4" => array(1, 2, 3, 4) ) ); 我的问题是:为什么我会收到此消息? Notice: Undefined offset: 0 in C:\wamp64\www\mazadi\tmpl\html.tpl on line 当给出 foreach() 时,为什么要使用 for():- <div class="personTools"> <ul> <?php foreach ($toolsMenu["TOOLS_MENU"] as $key=> $toolsM){ ?> <div class="dropdown"> <li><?php echo $key; ?> <span class="fa fa-caret-down"></span></li> <div class="dropdown-content"> <?php foreach ($toolsM as $tools) { ?> <li><?php echo $tools; ?> </li> <?php } ?> </div> </div> <?php } ?> </ul> </div> 注意:- 如果您能够使用 for 处理事情,请尽可能避免 foreach() 循环,因为 foreach() 会处理索引本身,而 for 循环则不会。


更新 MyBatis 中的值列表 - SQLSyntaxErrorException

更新 MyBatis 中的值列表时出现 SQLSyntaxErrorException。我正在使用分隔符=“;”在 forecach 标签中,但我仍然收到错误。下面是我的sql查询 更新 MyBatis 中的值列表时出现 SQLSyntaxErrorException。我在 forecach 标签中使用 separator=";" ,但仍然收到错误。下面是我的sql查询 <update id="updateComplianceCheckListResponse" parameterType="java.util.List"> <foreach collection="list" item="response" separator=";"> UPDATE AM_ComplianceChecklistResponse SET complianceDetailsId = #{response.complianceDetailsId}, complianceChecklistId = #{response.complianceChecklistId}, questionResponse = #{response.questionResponse}, expiryDate = #{response.expiryDate}, documentName = #{response.documentName}, comments = #{response.comments} WHERE id = #{response.id} </foreach> </update> org.apache.ibatis.exceptions.PersistenceException: 更新数据库时出错。原因:java.sql.SQLSyntaxErrorException:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在“UPDATE AM_ComplianceChecklistResponse”附近使用的正确语法 SET complianceDetailsId = 1, com' at line 10 错误可能存在于 com/am/dao/managecompliance/ComplianceChecklistResponse.xml 中 错误可能涉及ComplianceChecklistResponse.updateComplianceCheckListResponse-Inline 设置参数时出现错误 SQL: UPDATE AM_ComplianceChecklistResponse SETcomplianceDetailsId = ?,complianceChecklistId = ?,questionResponse = ?,expiryDate = ?,documentName = ?,comments = ?哪里 id = ? ; UPDATE AM_ComplianceChecklistResponse SET complianceDetailsId = ?、complianceChecklistId = ?、questionResponse = ?、expiryDate = ?、documentName = ?、comments = ?哪里 id = ? 原因:java.sql.SQLSyntaxErrorException:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在“UPDATE AM_ComplianceChecklistResponse”附近使用的正确语法 SET complianceDetailsId = 1, com' at line 10 at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:196) at com.am.dao.managecompliance.ComplianceChecklistResponseDAO.updateComplianceCheckListResponse(ComplianceChecklistResponseDAO.java:50) at com.am.service.managecompliance.ComplianceChecklistResponseService.updateComplianceCheckListResponse(ComplianceChecklistResponseService.java:122) at com.am.webservice.controller.managecompliance.ManageComplianceController.updateComplianceCheckListResponse(ManageComplianceController.java:230) at com.am.webservice.controller.managecompliance.ManageComplianceController$$FastClassBySpringCGLIB$$e3100610.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) at com.am.webservice.controller.managecompliance.ManageComplianceController$$EnhancerBySpringCGLIB$$4a5751a4.updateComplianceCheckListResponse(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:555) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:623) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:337) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) at com.dbp.security.auth.spring.StatelessAuthenticationFilter.doFilter(StatelessAuthenticationFilter.java:55) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:670) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1794) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:833) 引起:java.sql.SQLSyntaxErrorException:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在“UPDATE AM_ComplianceChecklistResponse”附近使用的正确语法 设置合规性详细信息 ID = 1, com' 在第 10 行 在 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) 在com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) 在com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916) 在 com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:354) 在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) 在java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.base/java.lang.reflect.Method.invoke(Method.java:568) 在org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) 在 jdk.proxy5/jdk.proxy5.$Proxy81.execute(来源未知) 在 org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) 在 org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) 在 org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) 在 org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) 在 org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) 在 org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194) ...省略69个常用框架 修复为 <insert id="updateComplianceCheckListResponse" parameterType="java.util.List"> insert into AM_ComplianceChecklistResponse (id,complianceDetailsId,complianceChecklistId,questionResponse,expiryDate,documentName,comments) VALUES <foreach collection="list" item="response" separator="," open="(" close=")"> #{response.id}, #{response.complianceDetailsId},#{response.complianceChecklistId},#{response.questionResponse},#{response.expiryDate},#{response.documentName},#{response.comments} </foreach> on duplicate key update complianceDetailsId= VALUES(complianceDetailsId), complianceChecklistId=VALUES(complianceChecklistId), questionResponse=VALUES(questionResponse), expiryDate=VALUES(expiryDate), documentName=VALUES(documentName), comments=VALUES(comments) </insert>


在这个curl api中将不记名授权令牌放在哪里

我正在使用 imageqrcode (https://imageqrcode.com/apidocumentation) 的新 api 功能来动态生成图像 QR 码,使用 php: 我正在使用 imageqrcode (https://imageqrcode.com/apidocumentation) 的新 api 功能来动态生成图像 QR 码,使用 php: <?php $api_key = 'xxxxxxxxxx'; //secret // instantiate data values $data = array( 'apikey' => $api_key, 'qrtype' => 'v1', 'color' => '000000', 'text' => 'https://wikipedia.com', ); // connect to api $url = 'https://app.imageqrcode.com/api/create/url'; $ch = curl_init($url); // Attach image file $imageFilePath = 'test1.jpg'; $imageFile = new CURLFile($imageFilePath, 'image/jpeg', 'file'); $data['file'] = $imageFile; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // Handle the response $result = json_decode($response, true); if ($result && isset($result['downloadURL'])) { // Successful request $download_url = $result['downloadURL']; echo "Download URL: $download_url"; } else { // Handle errors echo "Error: " . print_r($result, true); } ?> 在文档中显示有变量“serialkey”: 图片二维码API文档 API文档 生效日期:2023年11月15日 图像二维码 API 是一项接受 HTTPS 请求以生成图像或 gif 二维码的服务,主要由开发人员使用。 图像二维码 - URL JSON 请求(POST):https://app.imageqrcode.com/api/create/url apikey //你的apikey 序列号//你的序列号 qrtype //字符串,最少 2 个字符,最多 2 个字符v1 或 v2,v1 适用于 QR 类型 1,v2 适用于类型 2 color //数字,最小 6 位,最大 6 位,例如000000 为黑色 text //url,最少 15 个字符,最多 80 个字符https://yourwebsite.com file //图像文件 (jpg/jpeg/png),最大 1 MB 文件大小 现在没有信息将该序列密钥作为标准承载授权令牌放在哪里???如果没有此信息,我无法连接到 api 我尝试在没有不记名令牌的情况下连接它,因为我认为它可以匿名连接到 api,但也不起作用,我现在很困惑,因为我仍在学习 PHP 和 Laravel 看起来 serialkey 不是不记名令牌,而是一个应该与其他参数(如 apikey、qrtype、color、text 和 )一起包含在 POST 数据中的参数file。您可以在 PHP 代码的 serialkey 数组中包含 $data。 $data = array( 'apikey' => $api_key, 'serialkey' => 'your_serial_key', // Add this line 'qrtype' => 'v1', 'color' => '000000', 'text' => 'https://wikipedia.com', );


如何防止我的CSS规则被reactjs/jsx中的规范化CSS覆盖?

我有一个非常简单的反应组件 类 UpgradeContainer 扩展组件 { 使成为() { 返回 ( 我有一个非常简单的反应组件 class UpgradeContainer extends Component { render() { return ( <div className={styles.msg}> <div className={styles['msg-container']}> <h3 className={`${styles.title} highlight-color`}> Big Header </h3> <div className={`${styles.description} alternate-color`}> Small text <br /> Some more small text </div> </div> </div> ); } 这是相关的css .title { font-size: 40px; line-height: 50px; color: white; } .description { text-align: center; font-size: 16px; padding: 20px 0 10px; color: white; } 这是上面组件的 DOM 输出 此处以文本形式转载: <div class="mRMOZryRtlFUx_NHlt1WD" data-reactid=".0.1.0.0.0.1"> <h3 class="_2s6iXRZlq-nQwIsDADWnwU highlight-color" data-reactid=".0.1.0.0.0.1.0"> Big Header</h3> <div class="_1pFak-xR0a8YH6UtvoeloF alternate-color" data-reactid=".0.1.0.0.0.1.1"> <span data-reactid=".0.1.0.0.0.1.1.0">Small text</span> <br data-reactid=".0.1.0.0.0.1.1.1"> <span data-reactid=".0.1.0.0.0.1.1.2">Some more small text</span></div></div> 如你所见,reactjs 添加了几个 <span/> 来包裹小文本 我希望标题文本 (Big Header) 比描述文本(small text 和 some more small text)大得多。 输出看起来像这样: 这是因为reactjs出于某种原因添加了一个span来包裹文本small text和some more small text(data-reactid“.0.1.0.0.0.1.1.0”和“.0.1.0.0.0.1.1.2”分别) 当我检查样式时,我发现这些 span 元素的样式被以下 css 规则覆盖 我真的很困惑,因为这些规则不是我自己定义的。 所以我点击 <style>...</style>,它会将我带到 我想知道如何有效地覆盖这些CSS规则? 我想要的最终结果是: 如果您使用“Normalize.css”! 此问题的解决方案是将主 css 文件“style.css”保留在底部。至少低于normalize.css。 如果您使用 Bootstrap, 直接来自 Bootstrap 官方网站,“为了改进跨浏览器渲染,我们使用 Normalize.css,这是 Nicolas Gallagher 和 Jonathan Neal 的一个项目。” 这个问题的解决方案是将主 css 文件“style.css”保留在底部。至少低于 bootstrap.css。 我遇到了与您类似的问题,我的解决方案是在 app.tsx 文件顶部导入 Bootstrap 样式。这样做的原因是它可以防止 Bootstrap CSS 被应用程序中的其他样式覆盖,它对我有用


php 中的用户欢迎消息

如何在 php.ini 中创建用户欢迎消息这样已经登录的用户就能够看到他的用户名。 我有这段代码,但它似乎不起作用。 如何在 php.ini 中创建用户欢迎消息这样已经登录的用户就能够看到他的用户名。 我有这个代码,但它似乎不起作用。 <?php $con = mysql_connect("localhost","root","nitoryolai123$%^"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("school", $con); $result = mysql_query("SELECT * FROM users WHERE Username='$username'"); while($row = mysql_fetch_array($result)) { echo $row['Username']; echo "<br />"; } ?> 我正在尝试利用在此登录表单中输入的数据: <form name="form1" method="post" action="verifylogin.php"> <td> <table border="0" cellpadding="3" cellspacing="1" bgcolor=""> <tr> <td colspan="16" height="25" style="background:#5C915C; color:white; border:white 1px solid; text-align: left"><strong><font size="2">Login User</strong></td> </tr> <tr> <td width="30" height="35"><font size="2">Username:</td> <td width="30"><input name="myusername" type="text" id="idnum" maxlength="5"></td> </tr> <tr> <td width="30" height="35" ><font size="2">Password:</td> <td width="30"><input name="mypassword" type="password" id="lname" maxlength="15"></td> </tr> <td align="right" width="30"><td align="right" width="30"><input type="submit" name="Submit" value="Submit" /></td> <td align="right" width="30"><input type="reset" name="Reset" value="Reset"></td></td> </tr> </form> 但是这个 verifylogin.php 似乎很碍事。 <?php $host="localhost"; $username="root"; $password="nitoryolai123$%^"; $db_name="school"; $tbl_name="users"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:userpage.php"); } else { echo "Wrong Username or Password"; } ?> 我该怎么做?当我运行它时,我总是收到此错误: Notice: Undefined variable: username in C:\wamp\www\exp\userpage.php on line 53 您能推荐一个更简单的方法来实现同样的目标吗? $result = mysql_query("SELECT * FROM users WHERE Username='$username'"); 你忘记从某处定义和填充$username 您还需要添加 exit();在以下代码之后: session_register("myusername"); session_register("mypassword"); header("location:userpage.php"); exit(); ## EXIT REQUIRED 如果您不添加此内容并且客户端刷新,则会提示“您确定要重新提交已发布的变量吗?”如果他们单击“是”,那么您所有的登录逻辑将再次执行。在这种情况下,这可能不是致命的事情,但无论如何你都应该拥有它。 最重要的是:如果新用户登录,需要显示不同的名称,而不是显示以前的名称


显示多行文本的正确方法是什么?

我有一个 HTML 文档,其中有一些不同的文本行,是否有一些确定的正确方法来显示它们? 例子: 这里有 一些线路 文本的 我应该为每一行使用 标签,还是...... 我有一个 HTML 文档,其中包含一些不同的文本行,是否有一些确定的正确方法来显示它们? 示例: Here are some lines of text 我应该为每一行使用 <p> 标签,还是有其他/更好的方法来做到这一点? 示例: <p>Here are</p> <p>some lines</p> <p>of text</p> 或 <p> Here are <br> some lines <br> of text <br> </p> 或者完全不同的东西? CSS 和其他东西目前并不真正相关,我只是想知道哪种是“最正确”的使用方式。 如果您想在 div 中显示包含新行的字符串,则可以使用 white-space: pre-wrap css 样式: .multiline { white-space: pre-wrap; } <div class="multiline"> A multiline text for demo purpose </div> 或者你可以尝试this而不用标签换行每行: <div style="white-space:pre"> Here are some lines of text </div> 正确的做事方法是使用为你需要的东西而制作的东西。 如果您想要换行(输入),请使用 <br>; 如果要定义段落,请使用 <p>。 根据this,<br>元素用于插入换行符而不开始新段落。因此,与第一个解决方案相比,您应该更喜欢第二个解决方案。 w3schools 附带了一篇关于风格指南和编码约定的精彩文章。 规范非常清楚地表明,永远不要使用<br>,除非换行符实际上是形成单个文本单元的内容的一部分。 由于这些是不同的文本行,而不是恰好包含换行符的单个单元,因此需要将它们拆分为单独的 <p> 元素。 不存在最正确的方式,至少根据您当前的需求规范。是的,您可以使用 <p></p> 标签将它们全部放在单独的段落中,或者您可以通过每行的 <br> 标签将它们分开。您还可以将 span 与空白 CSS 属性结合使用,这样您就有很多选择。要选择最适合您的选项,您需要尝试一下,看看什么最适合您的要求。 如果您想创建一个多行段落来保持代码中的行分隔,而不到处乱扔。只需使用 html 标签即可。 使用 <pre> 标签就是您想要的: <pre> Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and line breaks </pre> “pre”代表“预格式化文本” https://www.w3schools.com/tags/tag_pre.asp


在仪表针中设置弹出框(Echarts)

我有这段代码,我尝试将鼠标悬停在第一个仪表针上以获取 .popover({...}) 对象: </sc...</desc> <question vote="0"> <p>我有这段代码,我尝试将鼠标悬停在第一个仪表针上以获取 .popover({...}) 对象:</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code> &lt;head&gt; &lt;script src=&#34;https://code.jquery.com/jquery-3.6.4.min.js&#34;&gt;&lt;/script&gt; &lt;script src=&#34;https://cdnjs.cloudflare.com/ajax/libs/echarts/5.3.0/echarts.min.js&#34;&gt;&lt;/script&gt; &lt;script src=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js&#34;&gt;&lt;/script&gt; &lt;link rel=&#34;stylesheet&#34; href=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css&#34;&gt; &lt;title&gt;Gauge Chart&lt;/title&gt; &lt;/head&gt; &lt;button id=&#39;btn1&#39;&gt; Let&#39;s &lt;/button&gt; &lt;input id=&#39;slider1&#39; type=&#39;range&#39; value=&#39;34&#39; min=&#39;0&#39; max=&#39;100&#39; step=&#39;.01&#39;&gt; &lt;input id=&#39;slider2&#39; type=&#39;range&#39; value=&#39;89&#39; min=&#39;0&#39; max=&#39;100&#39; step=&#39;.01&#39;&gt; &lt;div id=&#39;chartid1&#39; style=&#39;width:390px; height: 410px;&#39;&gt;&lt;/div&gt; &lt;script&gt; const chart1 = echarts.init(document.getElementById(&#39;chartid1&#39;)); function update1(value1, value2) { option = { series: [{ type: &#39;gauge&#39;, min: 0, max: 100, splitNumber: 10, detail: { fontFamily: &#39;Lato&#39;, fontSize: 14, borderWidth: 1, borderColor: &#39;#020202&#39;, borderRadius: 5, width: 32, height: 20 }, data: [{ value: value1, name: &#39;False&#39;, itemStyle: { color: &#39;#dd4b50&#39; }, title: { offsetCenter: [&#39;-20%&#39;, &#39;20%&#39;] }, detail: { offsetCenter: [&#39;-20%&#39;, &#39;36%&#39;], backgroundColor: &#39;#dd4b50&#39;, color: &#39;#f2f2f2&#39; } }, { value: value2, name: &#39;True&#39;, itemStyle: { color: &#39;#3a9e4b&#39; }, title: { offsetCenter: [&#39;20%&#39;, &#39;20%&#39;] }, detail: { offsetCenter: [&#39;20%&#39;, &#39;36%&#39;], color: &#39;#f2f2f2&#39;, backgroundColor: &#39;#3a9e4b&#39; } } ] }] }; chart1.setOption(option); } function update2() { let value1 = Number($(&#39;#slider1&#39;).val()); let value2 = Number($(&#34;#slider2&#34;).val()); update1(value1, value2); } update2(); document.getElementById(&#39;btn1&#39;).addEventListener(&#39;click&#39;, function() { update2(); }) /// clickable chart1.on(&#39;mouseenter&#39;, {dataIndex:0}, function(params) { $(this).popover({ html: true, sanitize: false, title: &#39;Title &#39;, content: &#39;This a text&#39;, trigger: &#39;hover&#39;, placement: &#39;top&#39;, container: &#39;body&#39; }) }) &lt;/script&gt;</code></pre> </div> </div> <p></p> <p>我需要悬停并获得 .popover。我知道我可以使用 <pre><code>tooltip:{...}</code></pre>,但对于特定情况,我需要配置 .popover。我尝试用 <pre><code>mychart1.on(...</code></pre> 调整上面的代码,但没有成功。我添加了所有代码需求的CDN。</p> </question> <answer tick="false" vote="0"> <p>如果您查看 <a href="https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseover" rel="nofollow noreferrer">文档</a>,该事件称为 <pre><code>mouseover</code></pre>,而不是 <pre><code>mouseenter</code></pre>。 <a href="https://echarts.apache.org/examples/en/editor.html?c=line-simple&code=PYBwLglsB2AEC8sDeAoWsDOBTAThLGAXLANprrLkWxgCeIWxA5AOYCGAri1kwDRUUAthGjEADP2rpBbAB7EAjGIkD0GEABsIYAHIdBAI1yKVU2ABMsYNhA3FUZ9ADMYYAGJthG2swAybMGA-VQoXaDAAZQgAL0ZYBQAWSUcDYBxLHAB1CHMwAAtFZLNU9NwAYWANNOYAYjEAJgaG4MdYEoyAJTZzCA4iWABWIqkAdxz84gBmeuHqPKwIFjywYkaQgF9ZiwC2YjJWh1bYADc2DQ44yaSQ6mhPOKYPDWwWo-0sQQi6DTjDo9gAMaVaqwJg1czmBIGAZiJg3CibeHoSBgH72JEUYBOJzYMBlLDhYykJgAWkaAFI-KCKUwALoYxH_SzWWzo_7oLE4qz4wk4Pakmm8UGTABslNpW2KbABAGsWDhgBxoOYKlU-aDwZDobDJVIgWrak56kajXD_ut4YzHH9HKdznEABwATl16DuggeABUcBdXq13p9vr8Meh9SCwZM2E6sFCzUcra0UWjKOzYJzcTywESSExBdSxOKGa6LFYbHYU-z09yCVn1Tm80xReLi6HgeqwSbjfU_UcDNK5QqlSq27VI9HYwzLSF6dQLeh6esANwoFeCWhlPJsHBgAB0MAAFExBIrsMBjrgqUhzDsAJLKrDyWBiTawJxKgGQA8gLeeDAASgrIFoAwSosB3KoWH3b8cF_P9l3WOCgA" rel="nofollow noreferrer">这里</a>是你的例子:</p> <pre><code>option = { series: [ { type: &#39;gauge&#39;, min: 0, max: 100, splitNumber: 10, detail: { fontFamily: &#39;Lato&#39;, fontSize: 14, borderWidth: 1, borderColor: &#39;#020202&#39;, borderRadius: 5, width: 32, height: 20 }, data: [ { value: 34, name: &#39;False&#39;, itemStyle: { color: &#39;#dd4b50&#39; }, title: { offsetCenter: [&#39;-20%&#39;, &#39;20%&#39;] }, detail: { offsetCenter: [&#39;-20%&#39;, &#39;36%&#39;], backgroundColor: &#39;#dd4b50&#39;, color: &#39;#f2f2f2&#39; } }, { value: 89, name: &#39;True&#39;, itemStyle: { color: &#39;#3a9e4b&#39; }, title: { offsetCenter: [&#39;20%&#39;, &#39;20%&#39;] }, detail: { offsetCenter: [&#39;20%&#39;, &#39;36%&#39;], color: &#39;#f2f2f2&#39;, backgroundColor: &#39;#3a9e4b&#39; } } ] } ] }; myChart.on(&#39;mouseover&#39;, {dataIndex: 0}, function(params) { console.log(params); }); </code></pre> </answer> </body></html>


PHP 函数 ssh2_connect 不起作用

以下是我的脚本: 以下是我的脚本: <?php $connection = ssh2_connect('XX.XX.XX.XX', 22); ssh2_auth_password($connection, 'root', '******'); $stream = ssh2_exec($connection, 'useradd -d /home/users/test -m testftp'); $stream = ssh2_exec($connection, 'passwd testftp'); $stream = ssh2_exec($connection, 'password'); $stream = ssh2_exec($connection, 'password'); ?> 它显示以下错误: Fatal error: Call to undefined function ssh2_connect() in /home/chaosnz/public_html/fotosnap.net/test.php on line 2 我该如何处理这个问题? 谢谢 老实说,我建议使用 phpseclib,这是一个纯 PHP SSH2 实现。示例: <?php include('Net/SSH2.php'); $ssh = new Net_SSH2('www.domain.tld'); if (!$ssh->login('username', 'password')) { exit('Login Failed'); } echo $ssh->exec('pwd'); echo $ssh->exec('ls -la'); ?> 它更加便携、更易于使用并且功能也更加丰富。 我已经安装了 SSH2 PECL 扩展,它工作正常,感谢大家的帮助... 我已经在 ubuntu 16.4 PHP 7.0.27-0+deb9u 和 nginx 上解决了这个问题 sudo apt install php-ssh2 您需要安装ssh2 lib sudo apt-get install libssh2-php && sudo /etc/init.d/apache2 restart 这应该足以让你上路 如果您在 OSX 上运行 bomebrew,我使用以下命令来安装它: brew install php56-ssh2 这对我有用。我从这里拉它。应该还有使用 mac 端口的 Ubuntu 和 OSX。 我正在运行 CentOS 5.6 作为我的开发环境,以下内容对我有用。 su - pecl install ssh2 echo "extension=ssh2.so" > /etc/php.d/ssh2.ini /etc/init.d/httpd restart 为了扩展 @neubert 答案,如果您使用 Laravel 5 或类似版本,您可以使用更简单的 phpseclib,如下所示: 奔跑composer require phpseclib/phpseclib ~2.0 在您的控制器中添加 use phpseclib\Net\SSH2; 然后在控制器方法中使用它,例如: $host = config('ssh.host'); $username = config('ssh.username'); $password = config('ssh.password'); $command = 'php version'; $ssh = new SSH2($host); if (!$ssh->login($username, $password)) { $output ='Login Failed'; } else{ $output = $ssh->exec($command); } 今天pecl install ssh2需要旧版本的php(<=6.0). Here https://pecl.php.net/package/ssh2您可以看到支持php7和php8的最新beta版本的ssh2。所以您应该安装其中之一: pecl install ssh2-1.3.1 * 不要忘记在 php.ini 文件中启用此 ssh2.so 扩展。 我知道有答案,但我只是在这里简化答案。 我有同样的问题,我在 ubuntu 20 中使用以下解决方案修复了它: sudo apt-get install libssh2-1 php7.1-ssh2 -y 您可以根据需要更改 php 版本,例如:php7.4-ssh2 参考:https://blog.programster.org/ubuntu-16-04-install-php-ssh2-extension 适用于 WHM 面板 菜单 > 服务器配置 > 终端: yum install libssh2-devel -y 菜单 > 软件 > 模块安装程序 PHP PECL 管理点击 ssh2 立即安装点击 菜单 > 重新启动服务 > HTTP 服务器 (Apache) 您确定要重新启动此服务吗? 是的 ssh2_connect() 工作了! 我觉得这个已有 11 年历史的讨论值得更新。我从 PHPSecLib 库切换到 PHP 7 和 8 的内置 SSH2 库,因为它似乎连接速度更快并且更标准。现在它还可以使用密钥密码,因此无需再使用第 3 方库。


如何防止点击时嵌套 React 组件中的事件冒泡?

这是一个基本组件。 和 都有 onClick 函数。我只想触发 上的 onClick,而不是 。我怎样才能实现这个目标? 我玩过 这是一个基本组件。 <ul> 和 <li> 都有 onClick 函数。我只想触发 <li> 上的 onClick,而不是 <ul>。我怎样才能实现这个目标? 我尝试过 e.preventDefault()、e.stopPropagation(),但无济于事。 class List extends React.Component { constructor(props) { super(props); } handleClick() { // do something } render() { return ( <ul onClick={(e) => { console.log('parent'); this.handleClick(); }} > <li onClick={(e) => { console.log('child'); // prevent default? prevent propagation? this.handleClick(); }} > </li> </ul> ) } } // => parent // => child 我也有同样的问题。我发现 stopPropagation did 有效。我会将列表项拆分为一个单独的组件,如下所示: class List extends React.Component { handleClick = e => { // do something } render() { return ( <ul onClick={this.handleClick}> <ListItem onClick={this.handleClick}>Item</ListItem> </ul> ) } } class ListItem extends React.Component { handleClick = e => { e.stopPropagation(); // <------ Here is the magic this.props.onClick(); } render() { return ( <li onClick={this.handleClick}> {this.props.children} </li> ) } } React 使用事件委托和文档上的单个事件侦听器来处理冒泡事件,例如本例中的“单击”,这意味着不可能停止传播;当您在 React 中与真实事件交互时,真实事件已经传播。 React 的合成事件上的 stopPropagation 是可能的,因为 React 在内部处理合成事件的传播。 stopPropagation: function(e){ e.stopPropagation(); e.nativeEvent.stopImmediatePropagation(); } 关于 DOM 事件的顺序:CAPTURING vs BUBBLING 事件传播有两个阶段。这些被称为 “捕获” 和 “冒泡”。 | | / \ ---------------| |----------------- ---------------| |----------------- | element1 | | | | element1 | | | | -----------| |----------- | | -----------| |----------- | | |element2 \ / | | | |element2 | | | | | ------------------------- | | ------------------------- | | Event CAPTURING | | Event BUBBLING | ----------------------------------- ----------------------------------- 首先发生捕获阶段,然后是冒泡阶段。当您使用常规 DOM api 注册事件时,默认情况下事件将成为冒泡阶段的一部分,但这可以在事件创建时指定 // CAPTURING event button.addEventListener('click', handleClick, true) // BUBBLING events button.addEventListener('click', handleClick, false) button.addEventListener('click', handleClick) 在React中,冒泡事件也是你默认使用的。 // handleClick is a BUBBLING (synthetic) event <button onClick={handleClick}></button> // handleClick is a CAPTURING (synthetic) event <button onClickCapture={handleClick}></button> 让我们看一下handleClick回调(React): function handleClick(e) { // This will prevent any synthetic events from firing after this one e.stopPropagation() } function handleClick(e) { // This will set e.defaultPrevented to true // (for all synthetic events firing after this one) e.preventDefault() } 我在这里没有看到提到的替代方案 如果您在所有事件中调用 e.preventDefault(),您可以检查事件是否已被处理,并防止再次处理它: handleEvent(e) { if (e.defaultPrevented) return // Exits here if event has been handled e.preventDefault() // Perform whatever you need to here. } 关于合成事件和原生事件的区别,请参阅React文档:https://reactjs.org/docs/events.html 这是防止单击事件前进到下一个组件然后调用 yourFunction 的简单方法。 <Button onClick={(e)=> {e.stopPropagation(); yourFunction(someParam)}}>Delete</Button> 这不是 100% 理想,但如果在儿童中传递 props 太痛苦 -> 儿童时尚或为此目的创建 Context.Provider/Context.Consumer just),你正在处理另一个库,它有自己的处理程序,它在您的处理程序之前运行,您也可以尝试: function myHandler(e) { e.persist(); e.nativeEvent.stopImmediatePropagation(); e.stopPropagation(); } 据我了解,event.persist方法可以防止对象立即被扔回React的SyntheticEvent池中。因此,当你伸手去拿 React 中传递的 event 时,它实际上并不存在!这种情况发生在孙子中,因为 React 在内部处理事情的方式是首先检查父进程是否有 SyntheticEvent 处理程序(特别是如果父进程有回调)。 只要您不调用 persist 来创建大量内存以继续创建诸如 onMouseMove 之类的事件(并且您没有创建某种 Cookie Clicker 游戏,例如 Grandma's Cookies),就应该完全没问题! 另请注意:偶尔阅读他们的 GitHub,我们应该密切关注 React 的未来版本,因为他们可能最终会解决一些问题,因为他们似乎打算在编译器中折叠 React 代码/转译器。 如果您希望发生嵌套元素中的操作而不是父元素中的操作,那么,您可以从父元素的操作处理程序中检查目标的类型,然后基于该类型执行操作,即,如果目标是我们的嵌套元素,我们什么也不做。否则两个处理程序都会被调用。 // Handler of the parent element. Let's assume the nested element is a checkbox function handleSingleSelection(e) { if(e.target.type !== 'checkbox') { // We do not do anything from the // parent handler if the target is a checkbox ( our nested element) // Note that the target will always be the nested element dispatch(lineSelectionSingle({ line })) } } 我在 event.stopPropagation() 工作时遇到问题。如果您也这样做,请尝试将其移动到单击处理程序函数的顶部,这就是我需要做的来阻止事件冒泡。示例函数: toggleFilter(e) { e.stopPropagation(); // If moved to the end of the function, will not work let target = e.target; let i = 10; // Sanity breaker while(true) { if (--i === 0) { return; } if (target.classList.contains("filter")) { target.classList.toggle("active"); break; } target = target.parentNode; } } 您可以通过检查事件目标来避免事件冒泡。 例如,如果您将输入嵌套到 div 元素,其中有单击事件的处理程序,并且您不想处理它,则单击输入时,您可以将 event.target 传递到您的处理程序中,并检查处理程序应该是根据目标的属性执行。 例如,您可以检查 if (target.localName === "input") { return}。 所以,这是一种“避免”处理程序执行的方法 解决此问题的另一种方法可能是在子级上设置 onMouseEnter 和 onMouseLeave 事件。 (您的 < li > 标签) 每当鼠标悬停在子级上时,您都可以设置一个特定的状态,以阻止父级执行 onClick 函数内容。 比如: class List extends React.Component { constructor(props) { super(props) this.state.overLi = false } handleClick() { // do something } render() { return ( <ul onClick={(e) => { if (!this.state.overLi) { console.log("parent") this.handleClick() } }} > <li onClick={(e) => { console.log("child") // prevent default? prevent propagation? this.handleClick() }} onMouseEnter={() => this.setState({ overLi: true, }) } onMouseLeave={() => this.setState({ overLi: false, })} ></li> </ul> ) } } 我进行了很多搜索,但没有设法使用 e.stopPropagation() 为我的上下文实现任何解决方案 您可以验证点击的元素是否是预期的元素。 例如: class List extends React.Component { constructor(props) { super(props); } handleClick(e) { if(e.target.className==='class-name'){ // do something } } render() { return ( <ul {/* Replace this with handleClick */} onClick={(e) => { console.log('parent'); this.handleClick(); }} <li onClick={(e) => { console.log('child'); // prevent default? prevent propagation? this.handleClick(); }} </li> </ul> ) } } 执行此操作的新方法更加简单,并且会节省您一些时间!只需将事件传递到原始点击处理程序并调用 preventDefault();。 clickHandler(e){ e.preventDefault(); //Your functionality here }


© www.soinside.com 2019 - 2024. All rights reserved.