我创建了一个vue组件,它有一个初始的ajax调用,用于获取我将循环遍历的对象数组.有没有办法将这些对象定义/转换为另一个vue组件?这是我到目前为止所得到的:
var myComponent = Vue.extend({
template: '#my-component',
created: function() {
this.$http
.get('/get_objects')
.then(function(data_array) {
for (var i = 0; i < data_array.data.length; i++) {
var item = data_array.data[i];
// <<-- How do i tell vue to cast another component type here??
}
}
);
}
});
Vue.component('my-component', myComponent);
new Vue({
el: 'body',
});
Run Code Online (Sandbox Code Playgroud) 我正在使用带有插件的gatsby gatsby-source-filesystem并将gatsby-transformer-remarkmarkdown文件显示为页面,如官方文档中所述。
效果很好,但是我正在寻找一种方法,将默认类添加到从markdown转换的所有元素中。
假设我希望每个<h1>元素都具有的类title,并且默认情况下<h2>元素要具有的类subtitle。
我设法通过进行了类似的操作gatsby-remark-attr,但是我只能以编程方式在markdown文件中添加类。看起来像这样:
# My markdown heading
{.title}
## Subtitle
{.subtitle}
Run Code Online (Sandbox Code Playgroud)
转换为
# My markdown heading
{.title}
## Subtitle
{.subtitle}
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种方法,为每个元素定义一次默认类,并自动应用它们,而不必在markdown文件中指定它们。