MVC与.js文件的棘手问题

MVC tricky issue with .js files

本文关键字:问题 文件 js MVC      更新时间:2023-09-26

在MVC中有2个视图说:

  View-A contains A.js which further contains function A()
  View-B contains B.js which further contains function B()

现在我想从View-B's B.js文件中调用function A()

我不能做什么:-

     #1 I can`t embed A.js into View-B
     #2 I can`t embed A.js into _Layout.cshtml

如果这是可能的,那么请告诉我怎么做?

您可以在视图 B 中使用getScript

$.getScript('jsfile.js',function(){
  //call function A 
});