2017-06-12 61 views
0

Main.js錯誤時設置require.js配置

require.config({ 
paths: { 
    ractive: "../lib/ractive", 
    rv: "../loaders/rv", 
    waitSeconds: 200 
}, 

name: "main", 
out: "../dist/js/main.js", 
stubModules: ["rv"]}); 

Feed.js

require(["../lib/ractive", "../loaders/rv!../templates/Feed/Main"], 
function (ractive, feedTemplate) { 
console.log(ractive); 
console.log(feedTemplate); 
    "use strict"; 

的Index.html

<script src="js/require.js" data-main="js/modules/Main" ></script> 
<script src="js/modules/Feed.js"></script> 

Ractive加載罰款,但RV不裝載好。

rv的錯誤消息。 Load timeout for modules: ../loaders/rv!../templates/Feed/Main_unnormalized2,ractive

有什麼我忘記了嗎?

回答

0

rvRequireJS plugin。由於您已將rv映射到其在paths配置中的路徑,因此您只需在其名稱後面加上!即可。

require(["../lib/ractive", "rv!../templates/Feed/Main"], ...);