我正在使用Laravel框架和laravel-elixir,jquery-slim,vuejs,vue-resource npm包。
我的问题是,当我尝试导入jquery插件(例如snackbarjs)时,由于jquery模块未被识别,因此给我一个问题。
错误:
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
我知道问题的来源,在这种情况下,snackbarjs尝试使用此代码来要求jquery插件:
import $ from 'jquery-slim';
import jQuery from 'jquery-slim';
import Vue from 'vue';
import VueResource from 'vue-resource';
import Vuex from 'vuex';
import 'snackbarjs';
Vue.use(VueResource);
Vue.use(Vuex);
我的app.js文件如下所示:
public class RecipeActivity extends AppCompatActivity {
private Recipe recipe;
private ActivityRecipeBinding binding;
private RecipeBinderHelper rbhelper = new RecipeBinderHelper();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
recipe = intent.getParcelableExtra("recipe");
binding = DataBindingUtil.setContentView(this, R.layout.activity_recipe);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(recipe.getName());
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
binding.recipeContent.setRecipe(recipe);
binding.recipeContent.setHelper(rbhelper);
binding.Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//HERE I CHANGE THE VALUE OF THE VARIBLE
rbhelper.setPresentationViewVisible(false);
binding.notifyChange();
}
});
}
}
有没有办法让snackbarjs忽略'jquery'模块要求或将模块的名称从'jquery-slim'更改为'jquery'?
提前致谢!