A couple of small improvements to the custom vue component example #4229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there, this is my first PR for this project and I'm somewhat new to collaborative Open Source development, so please be patient.
Description
This PR modifies the Custom Vue Component example to make it a bit more helpful for developers who need to create custom components but haven't used Vue before.
Motivation
In the example linked above, the Vue component is defined in
counter.js
. This way of bundling a component in a vanilla JavaScript file is obviously supported by Vue, since every built-in NiceGUI component is defined this way, but the official Vue documentation (and basically every other resource on the web) assumes that developers are writing.vue
files, which are supported by additional tooling. I think the example should structure its Vue code in a way that makes it easier for new developers to understand how it works in relation to existing Vue documentation.Changes
In the new modified example, the python class definition now uses a new file,
counter.vue
, which re-implementscounter.js
in the more customary Vue Single-File Component format.The call to
ui.run()
has been modified to ensure browser reload on changes to the.js
and.vue
files, which is important for iterative development on the Vue side.Testing
These changes do not add any new functionality that needs to be covered by tests. I have run the modified example and ensured that it does not error.
Additional Notes
I am curious if the developers would be interested in adding a second, more advanced custom vue component example. I am in the process of creating a pannable and zoomable image component, which I would be happy to wrap up in a nice example and provide in a separate PR.