微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用`h`创建一个非空的评论节点? 选项 1:h(null) 以字符串作为第二个参数选项 2:h(Comment) 以字符串作为第二个参数选项 3:createCommentVNode() 以字符串作为参数

如何解决如何使用`h`创建一个非空的评论节点? 选项 1:h(null) 以字符串作为第二个参数选项 2:h(Comment) 以字符串作为第二个参数选项 3:createCommentVNode() 以字符串作为参数

以下代码将产生一个空的评论节点,即using System; using System.Globalization; using System.Net; using System.Security.Cryptography; namespace ConsoleApp25 { class Program { static void Main(string[] args) { string Account = "storage_account_name"; string Key = "storage_account_key"; string FileShare = "file_share_name"; string FileName = "test555.txt"; string apiversion = "2019-02-02"; int content_length = 1200; string content_type = "text/plain"; DateTime dt = DateTime.UtcNow; string StringToSign = String.Format("PUT\n" + "\n" // content encoding + "\n" // content language + "\n" // content length + "\n" // content md5 + content_type + "\n" // content type + "\n" // date + "\n" // if modified since + "\n" // if match + "\n" // if none match + "\n" // if unmodified since + "\n" // range + "x-ms-content-length:" + content_length + "\nx-ms-date:" + dt.ToString("R") + "\nx-ms-file-attributes:Archive" + "\nx-ms-file-creation-time:Now" + "\nx-ms-file-last-write-time:Now" + "\nx-ms-file-permission:Inherit" + "\nx-ms-type:file" + "\nx-ms-version:" + apiversion + "\n" // headers + "/{0}/{1}/{2}",Account,FileShare,FileName); string auth = SignThis(StringToSign,Key,Account); string method = "PUT"; string urlPath = string.Format("https://{0}.file.core.windows.net/{1}/{2}",FileName); Uri uri = new Uri(urlPath); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method = method; request.ContentLength = 0; request.Headers.Add("x-ms-content-length",$"{content_length}"); request.Headers.Add("Content-Type",content_type); request.Headers.Add("x-ms-type","file"); request.Headers.Add("x-ms-date",dt.ToString("R")); request.Headers.Add("x-ms-version",apiversion); request.Headers.Add("x-ms-file-attributes","Archive"); //note it is case-sensitive. request.Headers.Add("x-ms-file-permission","Inherit"); request.Headers.Add("x-ms-file-creation-time","Now"); request.Headers.Add("x-ms-file-last-write-time","Now"); request.Headers.Add("Authorization",auth); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { //read the response code Console.WriteLine("the response is:" + response.StatusCode); } Console.WriteLine("**completed**"); Console.ReadLine(); } private static String SignThis(String StringToSign,string Key,string Account) { String signature = string.Empty; byte[] unicodeKey = Convert.FromBase64String(Key); using (HMACSHA256 hmacSha256 = new HMACSHA256(unicodeKey)) { Byte[] dataToHmac = System.Text.Encoding.UTF8.GetBytes(StringToSign); signature = Convert.ToBase64String(hmacSha256.ComputeHash(dataToHmac)); } String authorizationHeader = String.Format( CultureInfo.InvariantCulture,"{0} {1}:{2}","SharedKey",signature); return authorizationHeader; } } }
如何产生一个非空的评论节点,例如<!----> 使用 <!-- Foo -->

h

解决方法

选项 1:h(null) 以字符串作为第二个参数

export default {
  render(h) {
    return h(null,'This is a comment')  // <!--This is a comment-->
  },}

选项 2:h(Comment) 以字符串作为第二个参数

import { h,Comment } from 'vue' // Vue 3

export default {
  render() {
    return h(Comment,}

选项 3:createCommentVNode() 以字符串作为参数

import { createCommentVNode } from 'vue' // Vue 3

export default {
  render() {
    return createCommentVNode('This is a comment')  // <!--This is a comment-->
  },}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。