首页 \ 问答 \ 启用`strictNullChecks`后,`void`类型和`undefined`文字类型有什么区别?(With `strictNullChecks` enabled, what is the difference between the `void` type and `undefined` literal type?)

启用`strictNullChecks`后,`void`类型和`undefined`文字类型有什么区别?(With `strictNullChecks` enabled, what is the difference between the `void` type and `undefined` literal type?)

随着strictNullChecks启用:

(u: undefined, v: void, n: null) => {
  v = u;
  u = v; // type error: Type 'void' is not assignable to type 'undefined'
  v = n; // type error: Type 'null' is not assignable to type 'void'
}

我认为必须有一些类型为void值不是undefined类型,但启用了strictNullChecks我并不知道任何。 这个值是真的吗?


With strictNullChecks enabled:

(u: undefined, v: void, n: null) => {
  v = u;
  u = v; // type error: Type 'void' is not assignable to type 'undefined'
  v = n; // type error: Type 'null' is not assignable to type 'void'
}

I presume there must be some value of type void that is not of type undefined, but with strictNullChecks enabled I'm unaware of any. For which values is this true?


原文:https://stackoverflow.com/questions/42012387
更新时间:2022-01-11 18:01

最满意答案

如果将excel表保存为csv文件,则可以使用PHP“fopen”和“fgetcsv”。 也可以使用xlsx文件 - 如果没有,另存为csv。 处理完PHP后,您可以使用带有json_encode的Javascript来填充数组中的值。 见例子:

<?php  
        if (($handle = fopen("your file", "r")) !== FALSE) { 
            $i = 0;
            while (($lineArray = fgetcsv($handle, 10000, ";")) !== FALSE) { 
                for ($j=0; $j<count($lineArray); $j++) { 
                    $dataarray[$i][$j] = $lineArray[$j]; ");
                }
                $i++;
            } 
            fclose($handle); 
        }
?>

<script type="text/javascript">
    var data= <?php echo json_encode($dataarray); ?>;
</script>

You could use PHP "fopen" and "fgetcsv" if you save your excel sheet as a csv file. Could also work with a xlsx file - if not, save as csv. After processing the PHP you can use Javascript with json_encode to fill the values inside an array. See example:

<?php  
        if (($handle = fopen("your file", "r")) !== FALSE) { 
            $i = 0;
            while (($lineArray = fgetcsv($handle, 10000, ";")) !== FALSE) { 
                for ($j=0; $j<count($lineArray); $j++) { 
                    $dataarray[$i][$j] = $lineArray[$j]; ");
                }
                $i++;
            } 
            fclose($handle); 
        }
?>

<script type="text/javascript">
    var data= <?php echo json_encode($dataarray); ?>;
</script>

相关问答

更多
  • 在你Ajax中 编辑: 更改 datatype:"json", 参数名称的情况不被遵守,t必须是T dataType:"json", 现在请重试 $.ajax ({ url: 'index.php?page=register', //This is the current doc type: 'POST', dataType: 'json', data: {'userCheck': username}, success: function(data) { ...
  • 你的问题是mysqli_fetch_array 。 您想将MYSQLI_ASSOC作为第二个参数传递。 while($row=mysqli_fetch_array($results,MYSQLI_ASSOC)){ $json[]=$row; } 来自文档: 此可选参数是一个常量,指示应从当前行数据生成哪种类型的数组。 此参数的可能值是常量MYSQLI_ASSOC , MYSQLI_NUM或MYSQLI_BOTH 。 通过使用MYSQLI_ASSOC常量,此函数的行为与mysqli_fetch_as ...
  • 这是可能的,但您需要使用Multipart响应。 请记住,有些客户将无法处理这种类型的响应。 您通常会在上传文件时看到此数据类型,但并不经常用作响应数据类型。 话虽如此,下面是使用Jersey测试框架的完整示例。 在资源中,使用Jersey的FormDataMultiPart在响应中发送一个文件和一些额外的数据 @Path("test") public static class TestResource { @GET @Produces(MediaType.MULTIPART_FORM_DA ...
  • 尝试使用jQuery parseJSON方法。 var json = $.parseJSON(response); Try to use jQuery parseJSON method. var json = $.parseJSON(response);
  • alert(response.success); 会做到这一点,你可以添加dataType: 'json'到你的$ .ajax选项,以确保它被评估为回调中的一个对象。 alert(response.success); would do it, you can add dataType: 'json' to your $.ajax options to make absolutely sure it's evaluated as an object in your callback.
  • 我不知道有一种方法可以通过JS接收二进制数据,然后启动下载。 如果我接受了这个任务,我会将该方法更改为GET并生成文件(作为流)并将其返回给适当的头(Content-Disposition,Content-Length,Content-Type) I figure out a way around this. Instead of making a POST call to force the browser to open the save dialog, I will make a POST call ...
  • 尝试删除JSON.stringify(msg.response) 。 之后, msg.response.values[0].name应该给john Try removing the JSON.stringify(msg.response). After which, msg.response.values[0].name should givejohn
  • 如果将excel表保存为csv文件,则可以使用PHP“fopen”和“fgetcsv”。 也可以使用xlsx文件 - 如果没有,另存为csv。 处理完PHP后,您可以使用带有json_encode的Javascript来填充数组中的值。 见例子:
  • 查看Json解析器代码,它返回包含其他Dictionary对象(子键)的Dictionary对象,对于数组,还返回Collection Objects。 在Json中,我看到“shipping”是一个数组,因此解析器返回一个Collection Object。 因此,您可以使用所有Collection成员和方法来操作和访问它。 特别是,您可以使用Json("shipping").Count以检查Shipping集合中有多少元素。 或者你可以用For each x in Json("shipping")迭代集 ...
  • 你的json格式对我来说看起来不正确..你可以使用. 运算符以获取响应对象的值 var adv = response.NewDataSet.Table1; $("#QuickenName").html(adv.AUTONUM); alert(adv.AUTONUM); your json format does not looks correct to me anyways.. you can use . operator to get the response object's value ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)