我正在创建React驱动的应用程序,其加载方式与Google analitics相同:
/// <summary>
/// Async Init method
/// </summary>
/// <returns>Awaitable task with int as return value</returns>
public async Task<int> Init()
{
var p = new Product();
var productId = 10;
var UserId = 101;
Task updateProduct = null;
var count = 4;
if (count > 0)
{
//this will start UpdateProduct method in different thread (asynchronously)
updateProduct = p.UpdateProduct(productId, UserId);
}
//while UpdateProduct method is executing, other methods can be executed
if (count > 0)
{
var result = p.XYZ();
}
if (count > 0)
{
var result = p.ABC();
}
if (count > 0)
{
var result = p.MNC();
}
//------------etc (other stuff)------
//before leaving method, ensure UpdateProduct has finished its job
if (updateProduct != null)
await updateProduct;
return 1;
}
网站管理员将此小片段放入主机网页的HTML中,这将初始化小型React小部件。
正如您所看到的,该片段的效果是它会添加
<script>
(function(w, d, s, n, a, m) {
w[n] = w[n] || function() { (w[n].q = w[n].q || []).push(arguments) };
w[n].l = 1 * new Date();
a = d.createElement(s);
a.async = 1;
a.src = 'https://some.server.io/build/app.js';
m = d.getElementsByTagName(s)[0];
m.parentNode.insertBefore(a, m)
}(window, document, 'script', 'quant'));
quant('init', 'some-id');
</script>
到主页的DOM。
我的问题是,如果我需要发送修补程序,如何强制客户端的浏览器下载新版本的脚本(<script src="https://some.server.io/build/app.js" />
)?