请你帮我找一下问题的根源?
我想从bundle移动反应并从CDN加载它,所以我添加到webpack config:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
//not in an ispostback check
}
//but outside when working with dynamic controls
//create a new table
Table table = new Table();
//create a connection and a command
using (SqlConnection conn = new SqlConnection(ConnectionString))
using (SqlCommand cmd = new SqlCommand("select * from subjects", conn))
{
//open the connection
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
//create a new row, cell and checkbox
TableRow row = new TableRow();
TableCell cell = new TableCell();
CheckBox cb = new CheckBox();
//set some checkbox properties
cb.Text = reader["ColumnName"].ToString();
//add the checkbox to the cell
cell.Controls.Add(cb);
//the cell to the row
row.Controls.Add(cell);
//and the row to the table
table.Controls.Add(row);
}
}
}
//finally add the table to the page
PlaceHolder1.Controls.Add(table);
}
和html:
externals: {
react: {
root: 'react',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
umd: 'react',
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom',
umd: 'react-dom',
},
},
但在控制台我得到了:
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script async src="/client-2bb593ab57065d662f04.bundle.js"></script>
我不知道为什么,因为我已经简化了代码并删除了路由器。
有什么想法吗?尽我最大的问候。
答案 0 :(得分:0)
为了使其正常工作,我将libraryTarget: 'umd'
添加到webpack配置的output
。
在此处找到:https://github.com/webpack/webpack/issues/1275#issuecomment-246469528