未捕获到的SyntaxError:无效或意外的令牌@import CSS

时间:2018-11-03 14:08:24

标签: css extjs

编辑:这是一个错字-我使用脚本而不是错误地链接,并且没有注意到。因为已经给出了正确的答案,所以即使它很愚蠢,我也不会删除它。我只会接受答案。

我正在尝试学习 ExtJS 。 我已经在下面编写了简单的代码。我添加了neptune主题css文件以设置组件样式,但出现以下错误:

Uncaught SyntaxError: Invalid or unexpected token

在上述文件内的导入时发生错误:

@import 'theme-neptune-all_1.css';
@import 'theme-neptune-all_2.css';

我在做什么错?

<!DOCTYPE html>
<html>
   <head>
      <script type = "text/javascript" 
         src = "ext-6.6.0-trial/build/classic/theme-neptune/resources/theme-neptune-all.css"></script>
      <script type = "text/javascript" 
         src = "ext-6.6.0-trial/build/ext-all.js"></script>

      <script type = "text/javascript">
         Ext.onReady(function() {
            Ext.create('Ext.Panel', {
               renderTo: 'helloWorldPanel',
               height: 200,
               width: '50%',
               title: 'Hello world',
               html: 'First Ext JS Hello World Program'
            });

         });

      </script>
   </head>

   <body>
      <div id = "helloWorldPanel" />
   </body>
</html>

1 个答案:

答案 0 :(得分:1)

您做错了什么是告诉浏览器它将要阅读javascript,然后为其提供CSS。您想使用link元素而不是script标签来加载CSS。

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link