在svelte中导入javascript文件

时间:2019-07-01 16:23:01

标签: javascript html import svelte

所以今天我发现了Svelte,我绝对喜欢这个概念。我只有一个问题,我写了一个小的 helper.js 文件,但似乎无法导入它。每次我尝试引用我得到的课程

  

ReferenceError:未定义助手


main.js文件:

import App from './App.svelte';
import './helper.js';

var app = new App({
    target: document.body
});
export default app;


App.svelte文件:

<script>
    let helper = new Helper();
</script>

<h1>Hello</h1>


helper.js文件:

class Helper {
  constructor() {
    console.log("working");
  }
}

1 个答案:

答案 0 :(得分:6)

您需要将其导入使用它的文件中:

library(tidyverse)
library(ggforce)
ggplot(data = filter(Total, Cell_Line != "stDev"), aes(Time, Killing)) + 
  geom_line(data = transform(filter(Total, Cell_Line == "Wild_Type"), Cell_Line = NULL), group = 1) +
  geom_errorbar(data = Total %>% filter(Cell_Line %in% c("Wild_Type", "stDev")) %>% 
                  spread(Cell_Line, Killing),
                aes(x = Time, y = Wild_Type, ymax = Wild_Type + stDev, ymin = Wild_Type - stDev)) +      
  geom_point(colour = "cadetblue") +
  facet_grid_paginate(Cell_Line ~ Run, ncol = 4, nrow = 4)