如何在合金钛中导入小部件 [英] How to import a widget in alloy titanium

查看:19
本文介绍了如何在合金钛中导入小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新手问题:

我正在用合金 mvc 摆弄钛工作室,并开始掌握它的窍门.我不清楚如何将小部件导入到我的项目中.

I'm fiddling around with titanium studio with alloy mvc and starting to get the hang of it. It's just not clear to me how I can import a widget into my project.

我发现了一个不错的滑块菜单,并想在我自己的项目中使用它.

I found a nice slider menu and want to use this in my own project.

现在文档说你必须像这样在 config.json 中添加一个依赖项:

Now the docs say you have to add a dependency in the config.json like so:

    "dependencies": {
    "com.slider" : "1.0"
}

然后你就可以在你的视图中使用它了:

and then you'd be able to use it in your view:

<Widget src="com.slider"></Widget>

但是我不需要先将它导入到我的项目中吗?如果是这样,如何?将它作为项目导入只会将它添加到我的工作区,而不是我的项目用户/widgets/slider

But don't I need to import it into my project first? And if so, how? Importing it as a project only adds it to my workspace, not in my project user /widgets/slider

在构建时,我也收到以下错误:

Upon building this I also get the following error:

config.json references non-existent widgets: ["com.slider"]

我已经在谷歌上找了好几个小时了,但除了合金文档不包括导入之外,没有太多关于这方面的信息.

I've been looking for hours already on google but there's not much info on this besides the alloy docs that don't cover the importing thing.

帮助?

推荐答案

好的,所以您需要做的第一件事就是将小部件导入您的项目.

Allright, so first thing you need to do is IMPORT the widget into your project.

如果您查看合金项目的结构,您应该会在 app 文件夹中看到另一个名为widgets"的文件夹.将小部件复制并粘贴到其中,如下所示(文件夹名称不同,因为我使用了另一个滑块):

If you take a look at the structure of an alloy project you should see in the app folder another folder called "widgets". Copy and Paste the widget inside of it, something like this (the folder name is different because I use another slider):

然后在您的视图中(假设您有一个带有窗口的滑块的主视图):

Then in your view (let's say you have a main view for the slider with a window in it):

<Window id="mainWindow" class="container">
    <Require type="widget" src="com.slider" id="ds"/>
</Window>

最后,在你的 config.json 中:

Finally, in your config.json:

"dependencies": {       
   "com.slider":"1.0"
   }
 }

这篇关于如何在合金钛中导入小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆