我是Vue的新手.我正在尝试开发一个聊天应用程序,其中好友列表将显示在左侧菜单上,聊天框将显示在正文中.我正在使用ajax调用加载好友列表并根据好友ID路由到聊天框.这是代码示例.
<div class="chat-container clearfix" id="chat">
<div class="people-list" id="people-list">
<chatlist-component></chatlist-component>
</div>
<div class="chat">
<router-view></router-view>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
聊天列表组件将从服务器加载好友列表.这是我的app.js文件;
Vue.use(VueRouter)
const router = new VueRouter({
routes,
linkActiveClass: "active"
});
import ChatComponent from './components/ChatComponent';
const routes = [
{ path: '/chat/:id/:name', component: ChatComponent , name: 'chat'}
];
Vue.component('chatlist-component', require('./components/ChatlistComponent.vue'));
const app = new Vue({
el: '#chat',
router
});
Run Code Online (Sandbox Code Playgroud)
和聊天列表组件模板代码
<li class="clearfix" v-for="user in users">
<img :src="baseUrl+'/img/default_image.jpeg'" alt="avatar" class="chat-avatar rounded-circle" />
<router-link class="about" :to="{ name: 'chat', params: { id: user.id, name:user.name }}">
<div class="name">{{user.name}}</div>
<div …Run Code Online (Sandbox Code Playgroud) 我有一个全新安装的OSX el capitan 10.11.2并使用homebrew安装了php7.现在收到以下错误
命令
sudo apachectl -e info -k restart
Run Code Online (Sandbox Code Playgroud)
错误
httpd: Syntax error on line 171 of /private/etc/apache2/httpd.conf:
Cannot load /usr/local/opt/php70/libexec/apache2/libphp7.so into server: dlopen(/usr/local/opt/php70/libexec/apache2/libphp7.so, 10):
Library not loaded: /usr/local/opt/libxml2/lib/libxml2.2.dylib
Referenced from: /usr/local/opt/php70/libexec/apache2/libphp7.so
Reason: Incompatible library version: libphp7.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0
Run Code Online (Sandbox Code Playgroud)
我在谷歌搜索但没有得到任何具体的解决方案.
我有一个像下面这样的字符串......
Array ([product_name] => this is a product [product_desc] => some descripyion [cat_id] => 3)
Run Code Online (Sandbox Code Playgroud)
这看起来像一个数组,但这是一个字符串.如果我使用echo,它会打印相同的结果.
$someVariable = "Array ([product_name] => this is a product [product_desc] => some descripyion [cat_id] => 3)";
echo $someVariable;
Run Code Online (Sandbox Code Playgroud)
结果:
Array ([product_name] => this is a product [product_desc] => some descripyion [cat_id] => 3)
Run Code Online (Sandbox Code Playgroud)
我需要它转换为数组,以便我可以执行以下操作..
echo $someVariable['product_name'];
Run Code Online (Sandbox Code Playgroud)
并得到以下结果
this is a product
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
谢谢