该代码应弹出一个窗口,要求确认“按ok确认用户的操作”,但没有。我全都没主意了。
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var frm = new Form()
{
Text = "Data Grid View Form",
Name = "DataGridViewForm",
Size = new System.Drawing.Size(400, 400)
};
var dataGridView1 = new DataGridView();
var dataTable = new DataTable();
dataGridView1.DataSource = dataTable;
dataGridView1.Dock = DockStyle.Fill;
dataTable.Columns.Add("Id", typeof(int));
dataTable.Columns.Add("IdAsString", typeof(string));
var r1 = dataTable.NewRow();
r1["Id"] = 1;
r1["IdAsString"] = "1";
dataTable.Rows.Add(r1);
var r2 = dataTable.NewRow();
r2["Id"] = 11;
r2["IdAsString"] = "11";
dataTable.Rows.Add(r2);
var r3 = dataTable.NewRow();
r3["Id"] = 2;
r3["IdAsString"] = "2";
dataTable.Rows.Add(r3);
var r4 = dataTable.NewRow();
r4["Id"] = 22;
r4["IdAsString"] = "22";
dataTable.Rows.Add(r4);
frm.Controls.Add(dataGridView1);
Application.Run(frm);
}
}
}
PHP代码:
const { from } = require('rxjs');
const { map } = require('rxjs/operators');
const axios = require('axios');
const responsePromise = axios.get('https://jsonplaceholder.typicode.com/todos/1');
const response$ = from(responsePromise);
response$
.pipe(
map(response => ({ type: 'RESPONSE_RECEIVED', payload: response.data}))
)
.subscribe(console.log);
打开控制台,我看到“未捕获的SyntaxError:无效或意外的令牌”
答案 0 :(得分:1)
控制台问题与JavaScript代码的第2行和第3行有关;
var conf = confirm("Press OK to confirm the '"+type+"' action for user
<?php echo $u; ?>.");
您有一个多行字符串,控制台没有将其解释为一个字符串值。为了解决这个问题,ECMAScript 6 (ES6)引入了模板文字,可以像下面那样使用它来处理多行字符串;
var conf = confirm(`Press OK to confirm the '"+type+"' action for user
<?php echo $u; ?>.`);
(即使用反引号而不是双引号来开始和结束多行字符串)
或者,如果不支持ES6,则可以使用如下所示的旧式String串联;
var conf = confirm("Press OK to confirm the '"+type+"' action for user" +
"<?php echo $u; ?>.");