In Vuepress I can include components into the Markdown doing this:
<template>
<div class="thingy">
<Thingy/>
</div>
</template>
<script>
import Thingy from '../../components/Thingy'
export default {
components: {Thingy},
}
</script>
However it's quite long-winded. Is there a way to do this more tersely?
I suspect not at the moment and I was wondering if I could come up sith something and submit a pull request, but to be honest I haven't a clue how to implement that so any ideas would also be gratefully received.
If you place the component in /.vuepress/components/, Vuepress will register the component for you and you can just use it the markdown. The tag name is the same as the .vue file, so MyComponent.vue is used as
<MyComponent></MyComponent>
If you want to locate the component elsewhere, use enhanceApp.js as shown here vuepress - How to custom location of components directory...
Related
#section('contents') <app-employee-list></app-employee-list> #endsection
How I can get the full html structure form this? I can not found full code. but website is working.
This maybe a vue component, you can find it in this path
resources/js/components
OR it may be a laravel component, you can find it in this path
resources/views/components
I don't know, how much time I lost looking for solution for this issue. I wanted to use Chart.js in my Laravel project, so I followed instructions described here.
composer require fx3costa/laravelchartjs (runned)
Fx3costa\LaravelChartJs\Providers\ChartjsServiceProvider::class (added in the right place)
npm i chart.js (used to install chart.js)
In my controller and blade I used code from example 1 (Line Chart / Radar Chart)
After that the error appeared: Uncaught ReferenceError: Chart is not defined. Before and after that I was trying different solutions, but always something was wrong and I think this one should work for me. I probably missed something obvious, but very important.
Have you any ideas?
Should I add something to webpack.mix.js or bootstrap.js files after installing with npm?
EDIT:
If I put <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.js"></script> in my head section of blade, everything is working fine, but I'm using laravel-mix to use a locale file instead of link.
Chart.js must be loaded before content in order to use it in any Controller. I was loading my laravel-mix variables after HTML content (because it includes some big libralies like jQuery etc.), so that's why it couldn't work.
SOLUTION:
At the end of my document I still have my previous script
<script src="{{ asset('js/app.js') }}" ></script>
But now I made a new loadBefore.js file in resources/js directory with one line of code:
require('chart.js/dist/chart.js');
If there will be any reason to put there any other javascript code, it will be easy to put it there.
I also added this file to webpack.mix.js like this:
mix.js('resources/js/loadBefore.js', 'public/js').sourceMaps();
And of course at the end I added this script to the head section in my blade:
<script src="{{ asset('js/loadBefore.js') }}"></script>
Now everything is working and I'm using already existing in my Laravel files chart.js file. I don't know, someone knows an easier solution, so for now I'm accepting my answer, but I'm still open for suggestions.
why you just dont copy the content of
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.js"></script>
in a file at your local, for example: /public/js/chart.js
and load it in head
<script src="{{asset('js/chart.js')}}"></script>
My blade files often include Javascript to improve the user experience. Unfortunately, some of my users are still using IE 11 which does not have support for ES6, and causes my pages to fail with syntax errors. Is there any easy way to automatically transpile all the Javascript in blades? If not, should I create a common library that can be called by pages that need particular functions?
page.blade:
#extends('layouts.app')
#section('content')
<input id="field">
#endsection
#section('scripts')
<script>
const a = document.getElementById('field'); // or any ES6 js
const b = txt => console.log(txt);
</script>
#endsection
What I'm looking for is to have babel (or something) transpile that to ES5 in case my user is running IE. If possible, I'd also like to have an ES6 version and only serve that to a modern browser.
In resources/js/app.js there is this line: require('./bootstrap');.
If I add a line below that, require('./custom-stuff');, put custom-stuff.js in resources/js I can see that it's included in app.js. So far so good.
I'm puzzled however by the order that the files are included. If in custom-stuff.js I add:
$(function () {
$('[data-toggle="tooltip"]').tooltip()
});
it doesn't activate the tooltip, while I see the code being included in app.js.
If I add the tooltip activation code above in my Blade template right before the closing </body> tag (and before the inclusion of app.js), it does work.
Why is this? I would like to keep everything in app.js including custom code that refers to other libraries that are included.
You may try re-ordering the build combination in for your app.js and try checking your webpack.mix.js to do that.
I am using px-button-group design component as per the documentation
https://www.predix-ui.com/#/css/visual/buttons/px-button-group-design i installed the component i am using predix webapp starter (1.0.46 release version) as a reference app in my application.
in my project level we have index-inline.scss and seed-theme.scss and also we have scss files inside the elements folder like inside seed-app folder we have seed-app.scss under the seed-footer we have seed-footer.scss .
for our project requirement we have created some more custom polymer elements inside the same elements folder . we have rmd-view.html under the views folder , inside the rmd-view we are using these custom polymer elements which we have created like rotor-view and so on and also we are using the same seed-app.html for navigating page .
in rotor-view we want to use px-button-group design component for that I installed component and used below code in index-inline.scss in Object layer (as per https://github.com/predixdesignsystem/px-getting-started#import-order)
$inuit-btn-group-background : #09819c;
$inuit-btn-disabled-border : true;
#import "px-button-group-design/_objects.button-group.scss";
and included px-butto-group code as below in rotor-view.html
<div class="btn-group">
<input id="id1" name="btn-group" type="radio">
<label for="id1" class="btn">Label 1</label>
<input id="id2" name="btn-group" type="radio">
<label for="id2" class="btn">Label 2</label>
</div>
but it didnt work then i tried to use import in seed-app.scss then i also didnt work then tried to create new scss file named as rotor-view.scss inside the rotor-view folder (which is inside the elements folder)
this also didnt work for all above cases i am getting html radion button no button-group css is applying on above changes.
for testing i tried to use px-button-group-design html code in my seed-app.html then their i am getting proper button but i want to use in rotor-view looks like i am not using scss import on right place.
Can anyone please suggest me if i want to use px-button-group-design in rotor-view . in which scss file i should import button group scss ??
If you want to use the px-button-group in the seed-app.html component, then add it to the .scss file which generates the styles for seed-app.html component. If you want to use the px-button-group in the px-button-group in a child component, then add it to the .scss file which generates the styles for that component. Don't forget to import the styles with
<link rel="import" href="../my-styles.html">
And also include the styles in the DOM with
<style include="my-styles"></style>
Hope this helps.