我试图将x可编辑框架包含到我的项目中,但它不起作用。
如果我下载框架(从http://vitalets.github.io/x-editable/)并将其包含在packs/目录中,就会看到控制台中的TypeError: $(...).editable is not a function。
如果我将/layouts/application.html.slim,中的<script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.1/bootstrap3-editable/js/bootstrap-editable.min.js"></script>包括在内,则错误消息将更改
TypeError: this.tip(...) is undefined
顺便说一句,在javascript/packs/application.js i中,包括项目所需的框架(正如我猜想的那样):
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require('bootstrap')
require("jquery")
require('packs/announcements')
require('packs/bootstrap-tooltip')
require('packs/bootstrap-popover')
require('packs/bootstrap-editable')
require('packs/bootstrap-editable.min')函数‘提示’在bootstrap-tooltip.js中定义,但cdnjs.cloudflare.com不知道它。我做错了什么,如何将x编辑连接到我的项目中?
P.S.与x可编辑相关的其他部分,包括我在我的项目中有:
Gemfile:
gem 'twitter-bootstrap-rails'
gem 'x-editable-rails'assets/javascripts/application.js:
//= require jquery
//= require twitter/bootstrap
//= require editable/bootstrap-editable
//= require editable/rails
//= require_tree .发布于 2020-05-20 06:03:34
我不确定您是否在使用Webpacker,但是,如果您正在使用Webpacker,则可以执行以下操作:
1)加入纱线包装
yarn add x-editable2)在你的application.js中,或者如果你也在使用刺激,你可以把它放在你的控制器文件中
require('x-editable/dist/bootstrap3-editable/js/bootstrap-editable')
require('x-editable/dist/bootstrap3-editable/css/bootstrap-editable')并不是说x可编辑与Bootstrap 4不兼容,但它看起来很好。
https://stackoverflow.com/questions/59641347
复制相似问题