Scala播放`@ routes.Assets.versioned`导致非描述性错误

时间:2017-10-20 09:33:55

标签: scala playframework

我遇到浏览器缓存问题,所以我决定更改

loadwrk(): Promise<any> {
    return new Promise<any>((resolve, reject) => {
        this.storage.get('works').then(ow => {
            this.http.get(---url----).subscribe((res) => {
                let resonseData = res.json();
                if (JSON.stringify(ow) != JSON.stringify(resonseData)) {
                    console.log('i am new work');
                    resolve(resonseData);
                }
                else {
                    resolve(resonseData);
                    console.log('i am old work');
                }

            })
        })
    })
}

<script type="text/javascript" src="@routes.Assets.at("/accounts/dist/inline.bundle.js")"></script>

正如我们已经在其他项目中所做的那样,但我得到了这个完全没有用的错误:

<script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","inline.bundle.js")"></script>

这是C:\work\FrontServices\Spike2>sbt -jvm-debug 9999 run "C:\Users\xavier\.sbt\preloaded\org.scala-sbt\sbt\"1.0.2"\jars\sbt.jar" Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 Listening for transport dt_socket at address: 58387 [warn] Executing in batch mode. [warn] For better performance, hit [ENTER] to switch to interactive mode, or [warn] consider launching sbt without any commands, or explicitly passing 'shell' [info] Loading project definition from C:\Users\xavier\.sbt\0.13\staging\560eb781744c869bfbb7\sbt-coveralls\project [info] Loading project definition from C:\work\FrontServices\Spike2\project [info] Set current project to Spike2 (in build file:/C:/work/FrontServices/Spike2/) [info] Compiling 1 Scala source to C:\work\FrontServices\Spike2\modules\accounts\target\scala-2.11\classes... [error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:20: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call [error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","inline.bundle.js")"></script> [error] ^ [error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:21: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call [error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","polyfills.bundle.js")"></script> [error] ^ [error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:22: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call [error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","styles.bundle.js")"></script> [error] ^ [error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:23: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call [error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","vendor.bundle.js")"></script> [error] ^ [error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:24: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call [error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","main.bundle.js")"></script> [error] ^ [error] 5 errors found [error] (accounts/compile:compileIncremental) Compilation failed [error] Total time: 4 s, completed 20-Oct-2017 10:27:09 C:\work\FrontServices\Spike2> 文件

中的代码片段
routes

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

src="@routes.Assets.versioned("/public/accounts/dist","inline.bundle.js")" 为什么要在versioned()中用逗号分隔两个字符串。

这意味着你给了versioned()两个参数,因为它只会引发错误,因为它只会产生一个错误。

相反,你应该这样给它 -

src="@routes.Assets.versioned("/public/accounts/dist/inline.bundle.js")"

假设inline.bundle.js位于路径/public/accounts/dist/

尝试一下,让我知道它是否有效。我希望它能做到!

答案 1 :(得分:0)

在您正在执行的vector<A*> objectsvar; B var1; objectsvar.push_back(&var1); 定义中:

routes

这意味着方法GET /assets/*file controllers.Assets.versioned(path = "/public/accounts/dist", file: Asset) 的第一个参数已经定义(Assets.versioned)。因此,您只有一个参数(资产文件)的空间。但在您的观点中,您有:

path = "/public/accounts/dist"

换句话说,您正在尝试再次定义路径,但这是现在生成的反向路由器(<script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","inline.bundle.js")"></script> )而不是“原始”@routes.Assets,然后您会收到错误。< / p>

解决方案是更改代码以仅传递Assets.versioned参数:

file