[英]Import JS to Vue from node_modules
Forgive my lack of expertise, but I am attempting to integrate and import This Grid System Into my own Vue Setup and Im having some slight trouble. 原谅我缺乏专业知识,但我正在尝试将此网格系统集成并导入到我自己的Vue设置中,我遇到了一些麻烦。 Now, I normally import Plugins like so:
现在,我通常像这样导入插件:
import VuePlugin from 'vue-plugin'
Vue.use(VuePlugin)
and I'm then able to use the components of said plugin globally, however this is not a plugin and I'm having trouble pulling in/importing the needed components into my own components... suggestions? 然后我就可以在全局范围内使用所述插件的组件了,但是这不是一个插件,我在将所需组件导入/导入到我自己的组件中时遇到了麻烦...建议?
First, install: 首先,安装:
npm install --save vue-grid-layout
Then "register" it (probably a .vue
- or .js
- file): 然后“注册”它(可能是
.vue
- 或.js
- 文件):
import VueGridLayout from 'vue-grid-layout'
export default {
...
components: {
'GridLayout': VueGridLayout.GridLayout,
'GridItem': VueGridLayout.GridItem
}
<script>
tag: <script>
标签使用它: Naturally, add it somewhere: 当然,将它添加到某个地方:
<script src="some-cdn-or-folder/vue-grid-layout.min.js"></script>
And "register" it (propably a .js
file or another <script>
tag): 并“注册”它(可能是一个
.js
文件或另一个<script>
标签):
var GridLayout = VueGridLayout.GridLayout;
var GridItem = VueGridLayout.GridItem;
new Vue({
el: '#app',
components: {
"GridLayout": GridLayout,
"GridItem": GridItem
},
In both cases, you can then use <grid-layout ...></grid-layout>
in your template. 在这两种情况下,您都可以在模板中使用
<grid-layout ...></grid-layout>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.