Javascript TypeError:无法读取属性';getAttribute';空的

Javascript TypeError:无法读取属性';getAttribute';空的,javascript,html,Javascript,Html,正在尝试从Github添加日历控件。我收到这个信息 TypeError: Cannot read property 'getAttribute' of null at n (flatpickr:2) at ve (flatpickr:2) at ShowBins.aspx?env=*DEV&Elev=S &Name=DALLAS CTR&Site=31:74 HTML被称为ShowBins <link rel="stylesheet"

正在尝试从Github添加日历控件。我收到这个信息

TypeError: Cannot read property 'getAttribute' of null
    at n (flatpickr:2)
    at ve (flatpickr:2)
    at ShowBins.aspx?env=*DEV&Elev=S &Name=DALLAS CTR&Site=31:74
HTML被称为ShowBins

  <link rel="stylesheet" href="assets/main.css" />
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
  <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script> 
  <script>
      const today = new Date();
      const fp = flatpickr(document.querySelector("#datepicker"), { "maxDate": today });
</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server">
       <div class="form-group" style="background-color:white;">
               <asp:label ID="Label3" runat="server" class="auto-style32" Width="97px" >Date Shown:</asp:label>
                <asp:TextBox ID="datepicker" ClientIDMode="Static"  runat="server"  Width="100px" Font-Bold="true"  OnTextChanged="datepicker_OnTextChanged" AutoPostBack="true"></asp:TextBox>
                <asp:label ID="LblBins" text="Bins" runat="server" style="margin-left: 100px"></asp:label>
                <asp:DropDownList ID="DropDownBins" runat="server"  AutoPostBack="true"  OnSelectedIndexChanged="DropDownBins_SelectedIndexChanged" CssClass="auto-style28"  Width="50px" Height="22px" Font-Bold="true"></asp:DropDownList>
                <asp:label ID="LblStdTemp" text="Standard Temperature" runat="server" style="margin-left: 100px "  ></asp:label>
              <asp:TextBox ID="StdTemp"  runat="server" ClientIDMode="Static" CssClass="auto-style24" Width="20px"  OnTextChanged="StdTemp_TextChanged" AutoPostBack="true"  Font-Bold="true"></asp:TextBox>
           </div>

const today=新日期();
const fp=flatpickr(document.querySelector(“#datepicker”),{“maxDate”:today});
显示日期:

您没有将DOM元素作为目标,因为它在文档中的该点不存在

脚本需要在文档之后加载,将脚本放在body标记之后,这应该可以解决问题


:)

不清楚你在问什么。请编辑您的帖子,以包含我们用户可以回答的特定问题。