How to import a widget in alloy titanium

蹲街弑〆低调 提交于 2019-12-23 03:04:33

问题


Newbie question here:

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.

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>

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.

Help?


回答1:


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

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>

Finally, in your config.json:

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



回答2:


gitt.io is also great for finding and installing titanium widgets and modules

CLI installation: http://gitt.io/cli



来源:https://stackoverflow.com/questions/21525917/how-to-import-a-widget-in-alloy-titanium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!