如何在内容和弹出窗口之间共享常量?

时间:2018-10-21 11:40:34

标签: google-chrome-extension

我有以下设置。当我在 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.arewagirlcoder.welearn, PID: 13590 java.lang.NullPointerException: Attempt to invoke virtual method 'int com.arewagirlcoder.welearn.GroupModel.getImage()' on a null object reference at com.arewagirlcoder.welearn.GroupAdapter$GroupHolder.setImage(GroupAdapter.java:106) at com.arewagirlcoder.welearn.GroupAdapter.onBindViewHolder(GroupAdapter.java:50) at com.arewagirlcoder.welearn.GroupAdapter.onBindViewHolder(GroupAdapter.java:25) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6673) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6714) at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5647) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5913) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519) 中加入export语句时,我在global_constants.js中得到了unexpected token export

content.js中,导入语句所在的行出现了popup.js的错误。

我尝试了很多其他组合,但似乎无法使常量文件同时被弹出窗口和内容接受。

  • global_constants.js

    unexpected {
  • popup / popup.html

    const URL_REGEX = new RegExp("foobar");
    
  • popup / popup.js

    <head>
      <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    
      <link rel="stylesheet" href="popup.css">
    
      <script type="module" src="../global_constants.js"></script>
      <script src="popup.js"></script>
    
    </head>
    
  • mainfest.json

    import {URL_REGEX} from '../global_constants';    
    

0 个答案:

没有答案