如何正确预加载 google 字体

How to preload google fonts correctly

如何正确预加载 google 字体,而不在控制台中发出警告?

这是我的代码:

<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;600;700&family=Open+Sans:wght@100;400;700&display=swap"
          rel="preload" as="style" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;600;700&family=Open+Sans:wght@100;400;700&display=swap"
          rel="stylesheet">

我已经在预加载中添加了crossorigin属性link,但是警告还在

只需将 crossorigin 属性添加到主样式表

<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;600;700&family=Open+Sans:wght@100;400;700&display=swap"
          rel="preload" as="style" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;600;700&family=Open+Sans:wght@100;400;700&display=swap"
          rel="stylesheet" crossorigin="anonymous">